Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Check if player chatted?

Hello,

I am wondering how I check if a player has chatted, get their message, and send it to the database, with their username and their message. (I know HTTPService). So if you could just tell me how to get their message and their username (in a normal script preferably)!

Thanks, Ethan

4 comments

0

Community guidelines, please.

0

Each player has a Chatted event: http://wiki.roblox.com/index.php?title=API:Class/Player/Chatted. This should point you in the right direction.

0

Thanks, is there a way to get the players name in a normal script? Or no?

0

Dude, just send the player to the server via RemoteEvent from the LocalScript.

2 answers

game.Players.PlayerAdded:connect(function(player)
    player.Chatted:connect(function(msg)
        -- do stuff with msg and player
    end)
end)
game.Players.PlayerAdded:Connect(function(plr) -- grabs the player
plr.Chatted:Connect(function(msg) -- grabs plr message


	end) -- end message function
end) -- end playeradded function

I am not 100% sure about a database but Ill give you an example of how to use the functions

game.Players.PlayerAdded:Connect(function(plr) -- grabs the player
plr.Chatted:Connect(function(msg) -- grabs plr message

	if string.lower(msg) == 'hi' then
	print(plr.Name.. (' said hi')

		end -- ends the if statement
	end) -- end message function
end) -- end playeradded function

Hope this helps.

This discussion is preserved as it was. New answers, comments, and votes are closed.