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!!!
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.