I've been trying to create a script that teleports a player to a specific coordinate after typing a keyword in the chat. Unfortunately I haven't had any luck. Can someone please help me out? Thanks so much!!!
✓ ANSWER ACCEPTED
How do I create a chat-activated teleport within a place?
2 answers
✓ Accepted answer
Coordinate = CFrame.new(14.3, 0.5, 37.4)
game.Players.PlayerAdded:Connect(function(P) -- Check when a new player joined
P.Chatted:Connect(function(Msg) -- Check if person chatted
if string.lower(Msg) == "lol" then -- Check if they chatted our keyword "lol"
P.Character:SetPrimaryPartCFrame(Coordinate) -- teleport them
end
end)
end)
I encourage you to use SetPrimaryPartCFrame instead of setting the CFrame of a part on the player, The coordinate I took was a part position and turned it into a CFrame for it to work.
local Players = game:GetService("Players")
local Teams = game:GetService("Teams")
local tpCommand = "/teleport "
local function onPlayerChatted(player, message, recipient)
if message:sub(1, tpCommand:len()):lower() == tpCommand:lower() then
game.Workspace.Player.HumanoidRootPart.CFrame = CFrame.new(Vector3.new(0, 50, 0))
end
end
local function onPlayerAdded(player)
player.Chatted:Connect(function (...)
onPlayerChatted(player, ...)
end)
end
for _, player in pairs(Players:GetPlayers()) do
onPlayerAdded(player)
end
Players.PlayerAdded:Connect(onPlayerAdded)
Just ripped and re-wrote, you need to replace the CFrame with yours obviously.
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
You should use SetPrimaryPartCFrame instead. Theres no need to use :lower() on the tpCommand as it is already lowercase.
Like I said, I just ripped it straight off the Roblox Website I linked and changed like 3 things