i'm not sure how but this is what I tried.
script.Parent.MouseButton1Click:connect(function()
if game.Workspace.Gravity == 196.2 then
game.Workspace.Gravity = 60
else
game.Workspace.Gravity = 196.2
end
end)
i'm not sure how but this is what I tried.
script.Parent.MouseButton1Click:connect(function()
if game.Workspace.Gravity == 196.2 then
game.Workspace.Gravity = 60
else
game.Workspace.Gravity = 196.2
end
end)
This is a filtering issue. Set it on the server through a remote event:
--Local script
local remote = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent")
script.Parent.MouseButton1Click:Connect(function()
remote:FireServer()
end)
--Server script
local remote = Instance.new("RemoteEvent")
remote.Parent = game:GetService("ReplicatedStorage")
remote.OnServerEvent:Connect(function(plr)
if workspace.Gravity == 196.2 then
workspace.Gravity = 60
elseif workspace.Gravity == 60 then
workspace.Gravity = 196.2
end
end)
Resources:
Accept and upvote if this helped!
This discussion is preserved as it was. New answers, comments, and votes are closed.
6 comments
Connect NOT connect
It doesn't seem like there is anything inherently wrong with this code. Where are you running it? What does your hierarchy look like?
StarterGui>Gamepasses>MoonGravityGui>Button
You cannot change the gravity of the workspace within a local script. I recommend using a remote event (https://wiki.roblox.com/index.php?title=Remote_Functions_%26_Events)
You CAN change workspace gravity from a LocalScript, and it will change only that client's gravity. What behavior do you want OP, do you want to change everyone's gravity or just the gravity of LocalPlayer.
Just the LocalPlayer