Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Create the main GUI
- local ScreenGui = Instance.new("ScreenGui")
- ScreenGui.Parent = game.CoreGui
- -- Main Frame (Draggable)
- local Frame = Instance.new("Frame")
- Frame.Parent = ScreenGui
- Frame.Size = UDim2.new(0, 400, 0, 250)
- Frame.Position = UDim2.new(0.5, -200, 0.5, -125)
- Frame.BackgroundColor3 = Color3.fromRGB(20, 20, 20) -- Dark background color
- Frame.BorderSizePixel = 5
- Frame.BorderColor3 = Color3.fromRGB(255, 0, 0) -- Red border
- Frame.Draggable = true -- Makes the frame draggable
- Frame.Active = true
- -- Header Bar
- local Header = Instance.new("Frame")
- Header.Parent = Frame
- Header.Size = UDim2.new(1, 0, 0.1, 0)
- Header.BackgroundColor3 = Color3.fromRGB(10, 10, 10) -- Slightly darker background for header
- -- Title in Header
- local Title = Instance.new("TextLabel")
- Title.Parent = Header
- Title.Text = "Speed Adjuster"
- Title.Size = UDim2.new(1, 0, 1, 0)
- Title.TextSize = 20
- Title.TextColor3 = Color3.fromRGB(255, 255, 255) -- White text
- Title.BackgroundTransparency = 1
- Title.Font = Enum.Font.GothamBold
- Title.TextAlignment = Enum.TextAlignment.Center
- -- Speed Slider Label
- local SpeedLabel = Instance.new("TextLabel")
- SpeedLabel.Parent = Frame
- SpeedLabel.Text = "Speed: 16"
- SpeedLabel.Size = UDim2.new(1, 0, 0.1, 0)
- SpeedLabel.Position = UDim2.new(0, 0, 0.1, 0)
- SpeedLabel.TextSize = 16
- SpeedLabel.TextColor3 = Color3.fromRGB(255, 255, 255) -- White text
- SpeedLabel.BackgroundTransparency = 1
- SpeedLabel.TextAlignment = Enum.TextAlignment.Center
- -- Slider for Speed
- local Slider = Instance.new("Frame")
- Slider.Parent = Frame
- Slider.Size = UDim2.new(0.8, 0, 0.1, 0)
- Slider.Position = UDim2.new(0.1, 0, 0.2, 0)
- Slider.BackgroundColor3 = Color3.fromRGB(40, 40, 40) -- Dark background for slider
- Slider.BorderSizePixel = 0
- -- Slider Bar (Visual part of the slider)
- local SliderBar = Instance.new("Frame")
- SliderBar.Parent = Slider
- SliderBar.Size = UDim2.new(0, 0, 1, 0)
- SliderBar.BackgroundColor3 = Color3.fromRGB(0, 255, 0) -- Green color
- SliderBar.BorderSizePixel = 0
- -- Slider Button
- local SliderButton = Instance.new("Frame")
- SliderButton.Parent = Slider
- SliderButton.Size = UDim2.new(0, 20, 1, 0)
- SliderButton.BackgroundColor3 = Color3.fromRGB(255, 255, 255) -- White button for slider
- SliderButton.BorderSizePixel = 0
- SliderButton.Draggable = true -- Makes the slider button draggable
- -- Speed Adjustment Logic
- local speed = 16 -- Default speed
- local player = game.Players.LocalPlayer
- local character = player.Character or player.CharacterAdded:Wait()
- -- Function to update the speed
- local function updateSpeed(value)
- speed = math.floor(value) -- Round to nearest integer
- SpeedLabel.Text = "Speed: " .. speed
- character.Humanoid.WalkSpeed = speed -- Set the player's walk speed
- end
- -- Slider Button Dragging Logic
- SliderButton.InputBegan:Connect(function(input)
- if input.UserInputType == Enum.UserInputType.MouseButton1 then
- local startPos = input.Position.X
- local startSliderPos = SliderButton.Position.X.Offset
- local sliderWidth = Slider.AbsoluteSize.X
- local dragging = true
- local function onUpdate()
- if dragging then
- local delta = input.Position.X - startPos
- local newPos = math.clamp(startSliderPos + delta, 0, sliderWidth)
- SliderButton.Position = UDim2.new(0, newPos, 0, 0)
- SliderBar.Size = UDim2.new(newPos / sliderWidth, 0, 1, 0)
- updateSpeed((newPos / sliderWidth) * 300) -- Adjust max speed to 300
- end
- end
- -- Stop dragging
- input.Changed:Connect(function()
- if input.UserInputState == Enum.UserInputState.End then
- dragging = false
- end
- end)
- -- Update slider position while dragging
- game:GetService("RunService").Heartbeat:Connect(onUpdate)
- end
- end)
- -- Optional: Bind key to reset speed to default value
- game:GetService("UserInputService").InputBegan:Connect(function(input)
- if input.KeyCode == Enum.KeyCode.R then
- updateSpeed(16) -- Reset to default speed (16)
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement