Chat Commands

ServerScriptService

local tpCmd = "/tp "


local offset = Vector3.new(0,3,0)


local function teleport(player, spot)

local location = game.Workspace.tpLocations:FindFirstChild(spot)

if location then

player.Character.HumanoidRootPart.CFrame = CFrame.new(location.Position + offset)

end

end



game.Players.PlayerAdded:Connect(function(player)

player.Chatted:Connect(function (msg)

if msg:sub(1, tpCmd:len()):lower() == tpCmd:lower() then

print("teleport request")

local spot = msg:sub(tpCmd:len() + 1):lower()

print(spot)

teleport(player, spot)

end

end)

end)