Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do i fix this teleport script from not working?

Asked by 2 years ago

Hi, i made a script that's located in ServerScriptService. When a player says /jail username, it is meant to teleport them to a certain place on the map, however it isn't working.

game.Players.PlayerAdded:Connect(function(player)
    player.Chatted:Connect(function(msg)
        for i,player2 in pairs(game.Players:GetPlayers()) do
            if msg == "/jail "..player2.Name then
                player2.character.Torso.CFrame.new(34.5, 0.5, -66.7)
            end
        end
    end)
end)

Any help is hugely appreciated, thanks.

0
Try capitalizing the c in Character, that's what causes most problems in scripting. MendozaHM3SBulldog 32 — 2y
0
Mendoza is right. However I recommend putting the .Chatted function in StarterPlayerScripts and use RemoteEvent to fire in the server. T3_MasterGamer 2189 — 2y
0
And also try to split the message by using string.match() T3_MasterGamer 2189 — 2y

1 answer

Log in to vote
0
Answered by 2 years ago
Edited 2 years ago

You are not setting the CFrame of the torso properly.
I recommend changing line 5 to:

player2.Character.HumanoidRootPart.CFrame=CFrame.new(34.5, 0.5, -66.7)
Ad

Answer this question