Hello!
I want it so when a certain thing is said in the ROBLOX chat, an NPC teleports to the player that said the word.
The thing is, I do not know how to accomplish this. I’ve tried to make a script for it, but it doesn’t work. All I need is for the NPC to teleport to the player.
Here is my script:
local triggerwords = {"SCP2521", "SCP-2521", "2521", "2 5 2 1", "SCP 2521", "Twenty Five Twenty One", "Two Five Two One","TwoFiveTwoOne", "TwentyFiveTwentyOne", "TwoThousandFiveHundredTwentyOne", "Two Thousand Five Hundred Twenty One"} --table of trigger words
local Occupied = false
local PlayerValue = workspace.PlayerValue
function clone()
local SCP2521 = game.ServerStorage.SCP2521:Clone()
SCP2521.Parent = game.workspace
end
game.Players.PlayerAdded:Connect(function(plr)
plr.Chatted:Connect(function(msg)
for i = 1, #triggerwords do --I don't know how to use ipairs and pairs
local word = triggerwords[i]
local matchcheck = string.match(msg, word)
if matchcheck ~= nil and Occupied == false then
Occupied = true
if word == "SCP2521" or "SCP-2521" or "2521" or "2 5 2 1" or "SCP 2521" or "Twenty Five Twenty One" or "twenty five twenty one" or "Two Five Two One" or "two five two one" or "TwoFiveTwoOne" or "twofivetwoone" or "TwentyFiveTwentyOne" or "TwoThousandFiveHundredTwentyOne" or "Two Thousand Five Hundred Twenty One" then
local victim = plr.Name
local Value = PlayerValue.Value == victim
clone()
workspace.SCP2521.HumanoidRootPart.CFrame = workspace(PlayerValue.Value).HumanoidRootPart.CFrame
end
end
end
end)
end)
Any help is appreciated. Thanks!