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

How to make something happen when a player says something specific?

Okay so I'm trying to make a script that creates something when the player says something specific.

local player = game.Players.LocalPlayer
local torso = player.character:WaitForChild("Torso")
local pentagram = script.Parent

if torso.postion == pentagram.position then
	 player.Chatted:connect(function()
		
		
	end)
end

What do I use to write what I want the player to say?

1 answer

✓ Accepted answer

Alright

local player = game.Players.LocalPlayer
local torso = player.Character:WaitForChild("Torso")
local pentagram = script.Parent
local specificmessage = 'put your message here'

if torso.Postion == pentagram.Position then
	     player.Chatted:connect(function(message)
			if string.lower(message) == string.lower(specificmessage) then
				-- Put your code here
			end
	    end)
end

I've fixed up some simple mistakes.

You can change specificmessage to anything, and nothing here is case sensitive. Say the phrase "I hate pie" was specificmessage and the player chatted "I hAtE pIe", it would still trigger the code. As the comment implies, you can put anything there.

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