How do I make a repeatable .Chatted event

I’m currently making a .Chatted event for a GUI to change it image, here’s my script

game.Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(msg)
	if msg == "t" then
		player:WaitForChild("PlayerGui").ScreenGui.DChar.Image = "rbxassetid://"
	    end
    end)
end)

for some reasons the “t” can only be typed once and can’t be typed again

Hello. Do you mean to say that trying the command a second time does not work?

Also, kindly indent the Player.Chatted statement with a tab space.

1 Like

Yes, when I tried playing it and typed “t” the ScreenGui image changes, when the Image changes again and I try typing “t” again, the image didn’t change

Once the image changes, do you want it to hide the second time?

1 Like

Sorry to waste your time, I found a way to fix https://gyazo.com/93a155b146212b0cac5677df531c5438

1 Like

Where are you changing the image between saying t the two times? If that bit is on the client, the server won’t see the change so setting the Image again won’t do anything as it thinks the image is the same as it was last time they said t.

2 Likes

Hello,
is there a chance you are changing something with local script too?

1 Like

No, I found a way to fix it, by adding wait and changes to the other version of it.

Okay glad that you found the fix for this!
If you want you can include the fixed script because it can help somebody with same problem in future :wink:!

Sure!

game.Players.PlayerAdded:Connect(function(player)
	player.Chatted:Connect(function(msg)
		if msg == "t" or "T" then
			player:WaitForChild("PlayerGui").ScreenGui.DChar.Image = "rbxassetid://"
			wait(1)
			player:WaitForChild("PlayerGui").ScreenGui.DChar.Image = "rbxassetid://"
		end
	end)
end)
1 Like

Can you try typing “check” and what happens next? I have a feeling that it will still fire.