PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience

How to listen for and respond to a chat event

How to listen for and respond to a chat event

Jun 23 2018, 2:01 AM PST

Problem

You want to test a script that uses the Chatted event in Solo.

Solution

Use a StringValue with the .Changed event.

local p = game.Players.Player
Workspace.Value.Changed:connect(function(msg)
	-- etc...
end)

Discussion

You may have noticed that in Solo testing, there is no area where you can type to test scripts that involve the Chatted event. Therefore instead of doing:

game.Players.PlayerAdded:connect(function(p)
	p.Chatted:connect(function(msg)
		-- etc...
	end)
end)

We could use the code posted in the solution. So when you change the StringValue’s value, it will simulate the Chatted event.

Note: You could also use the Player object’s SetSuperSafeChat method, with false for argument. Doing this will make the chat bar appear.

game.Players.Player:SetSuperSafeChat(false)
Tags:
  • chat