GUI not enabling after I disable it

So, after I use a local script to disable the GUI, the GUI doesn’t seem to reappear when I use the proximity prompt.

Code that enables GUI using proximity prompt:

script.Parent.Triggered:Connect(function(plr)
	plr.PlayerGui.ShopGui.Enabled = true
end)

Script that uses text button to disable GUI:

local Players = game:GetService("Players")

script.Parent.TextButton.MouseButton1Click:Connect(function()
	Players.LocalPlayer.PlayerGui.ShopGui.Enabled = false
	if Players.LocalPlayer.PlayerGui.PlayerStats.Iron.Value >= 1 then
		game.ReplicatedStorage.PurchaseWeapon:FireServer()
	end
end)

The GUI will only enable again if I reset.

You would need to use a RemoteEvent in your Triggered method to achieve this. Since you’ve changed the ShopGui client side the server still thinks it is already enabled so it doesn’t do anything.

I guess you could also just set it to false and then true in your code and that would work.

script.Parent.Triggered:Connect(function(plr)
	plr.PlayerGui.ShopGui.Enabled = false
	plr.PlayerGui.ShopGui.Enabled = true
end)

Just a bit cleaner if you have the client doing the adjusting to ui elements but it works.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.