Advertisement
BrxndedB

Gravity Script

Jul 14th, 2024
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. -- LocalScript inside TextButton
  2.  
  3. local button = script.Parent
  4. local player = game.Players.LocalPlayer
  5. local character = player.Character or player.CharacterAdded:Wait()
  6. local userInputService = game:GetService("UserInputService")
  7. local gravity = 196.2 -- Default Roblox gravity
  8.  
  9. button.Text = "Set Gravity"
  10.  
  11. local function setGravity()
  12. local input = userInputService.InputBox("Enter desired gravity:", "Set Gravity", 196.2)
  13. input.FocusLost:Connect(function(enterPressed)
  14. if enterPressed then
  15. local newGravity = tonumber(input.Text)
  16. if newGravity then
  17. gravity = newGravity
  18. workspace.Gravity = gravity
  19. button.Text = "Gravity: " .. gravity
  20. else
  21. button.Text = "Invalid input"
  22. wait(1)
  23. button.Text = "Set Gravity"
  24. end
  25. end
  26. end)
  27. end
  28.  
  29. button.MouseButton1Click:Connect(setGravity)
  30.  
  31. -- Update gravity for new characters
  32. player.CharacterAdded:Connect(function(char)
  33. char:WaitForChild("HumanoidRootPart")
  34. workspace.Gravity = gravity
  35. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement