hello, I have had a little problem with this code, can someone help me?
the idea is this:
- when you click on the button your gravity changes (to normal or no gravity).
local player = game.Players.LocalPlayer
local gravityEnabled = true
local function toggleGravity()
gravityEnabled = not gravityEnabled
if gravityEnabled then
player.Character.HumanoidRootPart.Gravity = 196.2 -- normal gravity
else
player.Character.HumanoidRootPart.Gravity = 0 -- after click
end
end
local button = script.Parent
button.MouseButton1Click:Connect(function()
toggleGravity()
end)