Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 8 years ago

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

Log in to vote
1
Answered by 8 years ago

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.

Ad

Answer this question