Advertisement
Guest User

Roblox universal speed script-by Dia

a guest
Dec 5th, 2024
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.09 KB | None | 0 0
  1. -- Create the main GUI
  2. local ScreenGui = Instance.new("ScreenGui")
  3. ScreenGui.Parent = game.CoreGui
  4.  
  5. -- Main Frame (Draggable)
  6. local Frame = Instance.new("Frame")
  7. Frame.Parent = ScreenGui
  8. Frame.Size = UDim2.new(0, 400, 0, 250)
  9. Frame.Position = UDim2.new(0.5, -200, 0.5, -125)
  10. Frame.BackgroundColor3 = Color3.fromRGB(20, 20, 20) -- Dark background color
  11. Frame.BorderSizePixel = 5
  12. Frame.BorderColor3 = Color3.fromRGB(255, 0, 0) -- Red border
  13. Frame.Draggable = true -- Makes the frame draggable
  14. Frame.Active = true
  15.  
  16. -- Header Bar
  17. local Header = Instance.new("Frame")
  18. Header.Parent = Frame
  19. Header.Size = UDim2.new(1, 0, 0.1, 0)
  20. Header.BackgroundColor3 = Color3.fromRGB(10, 10, 10) -- Slightly darker background for header
  21.  
  22. -- Title in Header
  23. local Title = Instance.new("TextLabel")
  24. Title.Parent = Header
  25. Title.Text = "Speed Adjuster"
  26. Title.Size = UDim2.new(1, 0, 1, 0)
  27. Title.TextSize = 20
  28. Title.TextColor3 = Color3.fromRGB(255, 255, 255) -- White text
  29. Title.BackgroundTransparency = 1
  30. Title.Font = Enum.Font.GothamBold
  31. Title.TextAlignment = Enum.TextAlignment.Center
  32.  
  33. -- Speed Slider Label
  34. local SpeedLabel = Instance.new("TextLabel")
  35. SpeedLabel.Parent = Frame
  36. SpeedLabel.Text = "Speed: 16"
  37. SpeedLabel.Size = UDim2.new(1, 0, 0.1, 0)
  38. SpeedLabel.Position = UDim2.new(0, 0, 0.1, 0)
  39. SpeedLabel.TextSize = 16
  40. SpeedLabel.TextColor3 = Color3.fromRGB(255, 255, 255) -- White text
  41. SpeedLabel.BackgroundTransparency = 1
  42. SpeedLabel.TextAlignment = Enum.TextAlignment.Center
  43.  
  44. -- Slider for Speed
  45. local Slider = Instance.new("Frame")
  46. Slider.Parent = Frame
  47. Slider.Size = UDim2.new(0.8, 0, 0.1, 0)
  48. Slider.Position = UDim2.new(0.1, 0, 0.2, 0)
  49. Slider.BackgroundColor3 = Color3.fromRGB(40, 40, 40) -- Dark background for slider
  50. Slider.BorderSizePixel = 0
  51.  
  52. -- Slider Bar (Visual part of the slider)
  53. local SliderBar = Instance.new("Frame")
  54. SliderBar.Parent = Slider
  55. SliderBar.Size = UDim2.new(0, 0, 1, 0)
  56. SliderBar.BackgroundColor3 = Color3.fromRGB(0, 255, 0) -- Green color
  57. SliderBar.BorderSizePixel = 0
  58.  
  59. -- Slider Button
  60. local SliderButton = Instance.new("Frame")
  61. SliderButton.Parent = Slider
  62. SliderButton.Size = UDim2.new(0, 20, 1, 0)
  63. SliderButton.BackgroundColor3 = Color3.fromRGB(255, 255, 255) -- White button for slider
  64. SliderButton.BorderSizePixel = 0
  65. SliderButton.Draggable = true -- Makes the slider button draggable
  66.  
  67. -- Speed Adjustment Logic
  68. local speed = 16 -- Default speed
  69. local player = game.Players.LocalPlayer
  70. local character = player.Character or player.CharacterAdded:Wait()
  71.  
  72. -- Function to update the speed
  73. local function updateSpeed(value)
  74. speed = math.floor(value) -- Round to nearest integer
  75. SpeedLabel.Text = "Speed: " .. speed
  76. character.Humanoid.WalkSpeed = speed -- Set the player's walk speed
  77. end
  78.  
  79. -- Slider Button Dragging Logic
  80. SliderButton.InputBegan:Connect(function(input)
  81. if input.UserInputType == Enum.UserInputType.MouseButton1 then
  82. local startPos = input.Position.X
  83. local startSliderPos = SliderButton.Position.X.Offset
  84. local sliderWidth = Slider.AbsoluteSize.X
  85.  
  86. local dragging = true
  87. local function onUpdate()
  88. if dragging then
  89. local delta = input.Position.X - startPos
  90. local newPos = math.clamp(startSliderPos + delta, 0, sliderWidth)
  91. SliderButton.Position = UDim2.new(0, newPos, 0, 0)
  92. SliderBar.Size = UDim2.new(newPos / sliderWidth, 0, 1, 0)
  93. updateSpeed((newPos / sliderWidth) * 300) -- Adjust max speed to 300
  94. end
  95. end
  96.  
  97. -- Stop dragging
  98. input.Changed:Connect(function()
  99. if input.UserInputState == Enum.UserInputState.End then
  100. dragging = false
  101. end
  102. end)
  103.  
  104. -- Update slider position while dragging
  105. game:GetService("RunService").Heartbeat:Connect(onUpdate)
  106. end
  107. end)
  108.  
  109. -- Optional: Bind key to reset speed to default value
  110. game:GetService("UserInputService").InputBegan:Connect(function(input)
  111. if input.KeyCode == Enum.KeyCode.R then
  112. updateSpeed(16) -- Reset to default speed (16)
  113. end
  114. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement