GUI only appearing once

I’m trying to make a gui that appears when a player types /shop. The gui appears once when the player types /shop but once they exit out the gui and its removed the command no longer works again.


local MainPart = script.Parent
local GUI = game.ReplicatedStorage.CCStuff["Stadium Goods"]
local Range = 10

game.Players.PlayerAdded:Connect(function(Player)
	Player.Chatted:Connect(function(Text)
		if (Player.Character.HumanoidRootPart.Position - MainPart.Position).magnitude <= (Range) then
			if Text == "/shop" then
				if not Player.PlayerGui:FindFirstChild("Stadium Goods") then
					local GUI = game.ReplicatedStorage.CCStuff["Stadium Goods"]:Clone()
					GUI.Parent = Player.PlayerGui
				end
			end
		end
	end)
end)

I can’t really locate the problem, Are there any other scripts involved, etc?

It’s because even though when you press the exit button, the client sees that it’s invisible, while the server still thinks its visible.

You should try using a remote event to the client to handle the UI so that these problems don’t happen.

1 Like