Back to Library
UI
Nov 23, 2025
Teleport Command
T
by terrorsoul
Teleport to a position by using a chat command
LUA
function OnTeleportCommand(senderName, message, color)
-- Pattern match for "/tp X Y Z"
-- Example: /tp 0 50 0
local x, y, z = string.match(message, "/tp (%-?%d+) (%-?%d+) (%-?%d+)")
if x and y and z then
-- Find the player who sent the command
local players = tm.players.CurrentPlayers()
for _, p in pairs(players) do
if p.playerName == senderName then
-- Create vector from parsed strings
local newPos = tm.vector3.Create(tonumber(x), tonumber(y), tonumber(z))
-- Set position
local transform = tm.players.GetPlayerTransform(p.playerId)
transform.SetPosition(newPos)
tm.playerUI.AddSubtleMessageForPlayer(p.playerId, "TELEPORT", "Moved to " .. x .. "," .. y .. "," .. z, 3, "")
return
end
end
end
end
tm.playerUI.OnChatMessage.add(OnTeleportCommand)