Gui Scripts Not Working The Second Time

So I have this pc so that when you interact with it it turns off the old gui’s and turns on the new ones.

but when you go out of it and interact with it again it does this…

everything else works but the GUI only changes the first time that you press it.

This is because you change it to disabled locally, making the server think it is still enabled, therefore doesn’t make it enabled. On the server, change it to disabled and enabled at the same time or just change it to disabled on the server instead of the client.

1 Like

thank you so much this really helped

1 Like

I’d recommend using RemoteEvent instances (I know you didn’t recommend them to avoid confusion) but it’s best to have the client handle everything Gui-related through local scripts as to alleviate any unnecessary stress/strain on the server. Here’s an example of how that can be achieved with the involvement of a ProximityPrompt instance.

--SERVER
local Prompt = script.Parent
local Replicated = game:GetService("ReplicatedStorage")
local Remote = Replicated.Remote

Prompt.Triggered:Connect(function(Player)
	Remote:FireClient(Player)
end)
--LOCAL
local Gui = script.Parent
local Replicated = game:GetService("ReplicatedStorage")
local Remote = Replicated:WaitForChild("Remote")

Remote.OnClientEvent:Connect(function()
	Gui.Enabled = true
end)

These scripts are just an example, please do not copy & paste them expecting them to work.

With these scripts, if any other local script sets the “Enabled” property of the ScreenGui instance to false then when the ProximityPrompt instance is triggered the “Enabled” property will be correctly read as false and will be set to true.