Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 6 years ago
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!

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. jackfrost178 242 — 6y
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. jackfrost178 242 — 6y

1 answer

Log in to vote
0
Answered by
Fifkee 2017 Community Moderator Moderation Voter
6 years ago
Edited 6 years ago

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)

Ad

Answer this question