New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

How do I create a chat-activated teleport within a place?

Asked by 11 days ago

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

2 answers

Log in to vote
1
Answered by
Velsity 183
11 days ago
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.

Ad
Log in to vote
-1
Answered by 11 days ago

Roblox Player Chatted

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.

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

Answer this question