Gui will NOT Disable, Output says otherwise

Basically, there’s an X button to close a GUI. It doesn’t disable the GUI but the output says otherwise.

script.Parent.MouseButton1Click:Connect(function()
local player = script.Parent.Parent.Parent.Parent.Parent.Parent

print(script.Parent,script.Parent.Parent,script.Parent.Parent.Parent,script.Parent.Parent.Parent.Parent,script.Parent.Parent.Parent.Parent.Parent)
local gui =  player.PlayerGui:WaitForChild("BoothGui")
gui.Enabled = false
print(gui)
print('gui  disabled')

end)

image
I literally have no idea why this Isn’t working.
image

Does anyone know what’s happening?

You are using a server script inside of a GUI. Try changing this to a LocalScript

With this, you can set the player variable to game.Players.LocalPlayer

you can use server scripts in StarterGui, but yea it is better to do this locally instead of doing it for everyone on the server

1 Like

Its weird that it works in only local scripts but im glad. Most of my Gui Stuff is in serverscripts and still functions normally.

Mhm. Sometimes you can get away with it, but you should try to stick to doing GUI scripts locally. Glad to help!

2 Likes