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

How to trigger events using the Chat?

So Im making a small game and I need to make an object move when someone says the keyword in chat, does anyone know that code for this?

1 answer

You would use the 'Chatted' function with the "message" parameter.

It would look something like this...

You can either use a server script,

game.Players.PlayerAdded:Connect(function(plr)

	plr.Chatted:Connect(function(msg)
		

		if msg == "" then --What word activates the function
			--Your code here
		end

	end)


end)

Or a local script with remote events/functions

local plr = game:GetService("Players").LocalPlayer
local Storage = game:GetService("ReplicatedStorage")
local Remote = Storage:WaitForChild("Remote")

plr.Chatted:Connect(function(msg)


	if msg == "" then

		Remote:FireServer(msg)

	end


end)

For more information, visit the developer forums: [https://developer.roblox.com/en-us/api-reference/event/Player/Chatted]

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