Gui via chat command only opens once

Hello,

I am making a gui so that when an admin says something, a gui will popup for them.
It works the first time, but when I close the gui and open it again, it doesn’t open.

local admins = {"ChickenCrat"}

function onChatted(msg, recipient, speaker)  

	
	msg = string.lower(msg) 

	if (msg == ";admin") then 

		if table.find(admins,speaker.Name) then
			game.Players[speaker.Name].PlayerGui.adminUtils.Background.Visible = true
		end
	end 

end 

function onPlayerEntered(newPlayer) 
	newPlayer.Chatted:Connect(function(msg, recipient) onChatted(msg, recipient, newPlayer) end) 
end 

game.Players.PlayerAdded:Connect(onPlayerEntered) 

It should open the background frame everytime when the visible property is false, but it only works once and not again. I’m not too familiar with chat functions.

Inside the gui there is an exit button which just makes the background visible = false.

Thanks for reading,
ChickenCrat

Use :FireClient() or place the ui inside the player gui when chatted, and when closed simply destroy the gui.

Thank you very much, this worked perfectly!

1 Like

You encountered a client-server replication issue, the server was setting the frame’s ‘Visible’ property to true and the client was setting the frame’s ‘Visible’ property to false, changes made by the server replicate to the client whereas changes made by the client do not replicate to the server.

1 Like