Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

GUI toggle script only works in Studios test mode. Any solutions?

local rs = game:GetService("ReplicatedStorage")
local plr = script.Parent.Parent.Parent.Parent.Parent
function onClick()
	if
		plr.PlayerGui.GameGui.Enabled == true
		then
	rs.ToggledEvent:FireServer()
	elseif
		plr.PlayerGui.GameGui.Enabled == false
		then
		rs.UnToggledEvent:FireServer()
	end
	end
script.Parent.MouseButton1Click:connect(onClick)

help would be appreciated!

2 comments

0

Its a GUI, you dont have to call the server to set the Enabled property to true or else, you can just do it from the local script.

0

Also i believe you can just do plr.PlayerGui.GameGui.Enabled = not plr.PlayerGui.GameGui.Enabled in one line instead of the if statement.

1 answer

✓ Accepted answer

If only the client can see it, then you don't really need to use events.

local plr = game.Players.LocalPlayer
local Gui = plr.PlayerGui.GameGui

function onClick()
        Gui.Enabled == not Gui.Enabled
end)

script.Parent.MouseButton1Click:connect(onClick)

This discussion is preserved as it was. New answers, comments, and votes are closed.