0% found this document useful (0 votes)
113 views3 pages

Custom Run

Uploaded by

battacricket
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
113 views3 pages

Custom Run

Uploaded by

battacricket
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

-- Roblox Lua Script for a Draggable GUI with Speed Slider and Persistent Speed

-- Ensure you use a reliable executor for this script.

-- Create the GUI


local ScreenGui = Instance.new("ScreenGui")
local MainFrame = Instance.new("Frame")
local ToggleButton = Instance.new("TextButton")
local ToggleLight = Instance.new("Frame")
local Slider = Instance.new("Frame")
local SliderBar = Instance.new("Frame")
local SliderButton = Instance.new("TextButton")
local SpeedDisplay = Instance.new("TextLabel")
local ApplyButton = Instance.new("TextButton")

-- Enable the GUI to be draggable


local UIS = game:GetService("UserInputService")
local dragging
local dragInput
local dragStart
local startPos

local function makeDraggable(frame)


frame.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
dragging = true
dragStart = input.Position
startPos = frame.Position

input.Changed:Connect(function()
if input.UserInputState == Enum.UserInputState.End then
dragging = false
end
end)
end
end)

frame.InputChanged:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseMovement then
dragInput = input
end
end)

UIS.InputChanged:Connect(function(input)
if input == dragInput and dragging then
local delta = input.Position - dragStart
frame.Position = UDim2.new(
startPos.X.Scale,
startPos.X.Offset + delta.X,
startPos.Y.Scale,
startPos.Y.Offset + delta.Y
)
end
end)
end

-- GUI Properties
ScreenGui.Parent = game.CoreGui

MainFrame.Parent = ScreenGui
MainFrame.BackgroundColor3 = Color3.fromRGB(50, 50, 50)
MainFrame.Position = UDim2.new(0.3, 0, 0.3, 0)
MainFrame.Size = UDim2.new(0, 300, 0, 200)
makeDraggable(MainFrame)

ToggleButton.Parent = MainFrame
ToggleButton.BackgroundColor3 = Color3.fromRGB(80, 80, 80)
ToggleButton.Position = UDim2.new(0, 10, 0, 10)
ToggleButton.Size = UDim2.new(0, 80, 0, 30)
ToggleButton.Text = "Toggle"

ToggleLight.Parent = ToggleButton
ToggleLight.BackgroundColor3 = Color3.fromRGB(255, 0, 0)
ToggleLight.Position = UDim2.new(0.8, 0, 0.2, 0)
ToggleLight.Size = UDim2.new(0, 10, 0, 10)

Slider.Parent = MainFrame
Slider.BackgroundColor3 = Color3.fromRGB(60, 60, 60)
Slider.Position = UDim2.new(0, 10, 0, 50)
Slider.Size = UDim2.new(0, 280, 0, 20)

SliderBar.Parent = Slider
SliderBar.BackgroundColor3 = Color3.fromRGB(100, 100, 100)
SliderBar.Position = UDim2.new(0, 5, 0.5, -2)
SliderBar.Size = UDim2.new(1, -10, 0, 4)

SliderButton.Parent = Slider
SliderButton.BackgroundColor3 = Color3.fromRGB(200, 200, 200)
SliderButton.Position = UDim2.new(0, 0, 0, 0)
SliderButton.Size = UDim2.new(0, 10, 1, 0)
SliderButton.Text = ""

SpeedDisplay.Parent = MainFrame
SpeedDisplay.BackgroundColor3 = Color3.fromRGB(80, 80, 80)
SpeedDisplay.Position = UDim2.new(0, 10, 0, 80)
SpeedDisplay.Size = UDim2.new(0, 280, 0, 30)
SpeedDisplay.Text = "Speed: 1"

ApplyButton.Parent = MainFrame
ApplyButton.BackgroundColor3 = Color3.fromRGB(80, 80, 80)
ApplyButton.Position = UDim2.new(0, 10, 0, 120)
ApplyButton.Size = UDim2.new(0, 280, 0, 30)
ApplyButton.Text = "Apply Speed"

-- Script Variables
local sliderMax = 100
local sliderMin = 1
local sliderStep = 0.5
local isEnabled = false
local speed = sliderMin

-- Update Slider Position and Speed Display


SliderButton.MouseButton1Down:Connect(function()
local inputConn, releaseConn
inputConn = UIS.InputChanged:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseMovement then
local relativeX = math.clamp(
(input.Position.X - Slider.AbsolutePosition.X) /
Slider.AbsoluteSize.X,
0, 1
)
local roundedSpeed = math.floor((sliderMin + (sliderMax - sliderMin) *
relativeX) / sliderStep) * sliderStep
speed = roundedSpeed
SpeedDisplay.Text = "Speed: " .. tostring(speed)
SliderButton.Position = UDim2.new(relativeX, 0, 0, 0)
end
end)

releaseConn = UIS.InputEnded:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
inputConn:Disconnect()
releaseConn:Disconnect()
end
end)
end)

-- Toggle Functionality
ToggleButton.MouseButton1Click:Connect(function()
isEnabled = not isEnabled
ToggleLight.BackgroundColor3 = isEnabled and Color3.fromRGB(0, 255, 0) or
Color3.fromRGB(255, 0, 0)
end)

-- Apply Speed Functionality


ApplyButton.MouseButton1Click:Connect(function()
if isEnabled then
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:FindFirstChildOfClass("Humanoid")

if humanoid then
humanoid.WalkSpeed = speed
end
end
end)

-- Continuous Speed Enforcement


spawn(function()
while true do
if isEnabled then
local player = game.Players.LocalPlayer
local character = player.Character
if character then
local humanoid = character:FindFirstChildOfClass("Humanoid")
if humanoid then
humanoid.WalkSpeed = speed
end
end
end
wait(0.05) -- Loop every 0.05 seconds
end
end)

You might also like