Advertisement
Zwiebelle1301706

Untitled

May 8th, 2024
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.36 KB | None | 0 0
  1.  
  2.  
  3. local function setPlayerSpeed(speed)
  4. local character = game.Players.LocalPlayer.Character
  5. if character then
  6. local humanoid = character:FindFirstChildOfClass("Humanoid")
  7. if humanoid then
  8. humanoid.WalkSpeed = speed
  9. end
  10. end
  11. end
  12.  
  13. -- Create a ScreenGui for the speed input
  14. local screenGui = Instance.new("ScreenGui")
  15. screenGui.Name = "SpeedInputGui"
  16. screenGui.Parent = game.Players.LocalPlayer.PlayerGui
  17.  
  18. -- Create a TextBox for input
  19. local textBox = Instance.new("TextBox")
  20. textBox.Name = "SpeedInput"
  21. textBox.PlaceholderText = "Enter speed..."
  22. textBox.Size = UDim2.new(0, 200, 0, 30)
  23. textBox.Position = UDim2.new(0.5, -100, 0.5, -15)
  24. textBox.AnchorPoint = Vector2.new(0.5, 0.5)
  25. textBox.BackgroundTransparency = 0.5 -- Set background transparency to make it semi-transparent
  26. textBox.BackgroundColor3 = Color3.new(1, 1, 1) -- Set background color to white
  27. textBox.BorderSizePixel = 0 -- Remove border
  28. textBox.TextColor3 = Color3.new(0, 0, 0) -- Set text color to black
  29. textBox.Font = Enum.Font.SourceSans
  30. textBox.TextSize = 14
  31. textBox.Parent = screenGui
  32.  
  33. -- Apply rounded corners to the TextBox
  34. local corner = Instance.new("UICorner")
  35. corner.CornerRadius = UDim.new(0, 5) -- Set corner radius to 5 pixels
  36. corner.Parent = textBox
  37.  
  38. -- Function to handle input changes
  39. textBox.FocusLost:Connect(function(enterPressed)
  40. if enterPressed then
  41. local inputText = textBox.Text
  42. local speed = tonumber(inputText)
  43. if speed then
  44. setPlayerSpeed(speed)
  45. else
  46. textBox.Text = "Invalid input"
  47. wait(2)
  48. textBox.Text = ""
  49. end
  50. end
  51. end)
  52.  
  53. -- Function to toggle GUI visibility
  54. local guiVisible = true
  55. local function toggleGuiVisibility()
  56. guiVisible = not guiVisible
  57. screenGui.Enabled = guiVisible
  58. end
  59.  
  60. -- Toggle GUI visibility when T key is pressed
  61. game:GetService("UserInputService").InputBegan:Connect(function(input)
  62. if input.KeyCode == Enum.KeyCode.T then
  63. toggleGuiVisibility()
  64. end
  65. end)
  66.  
  67.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement