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

How can I teleport all players who enter my world to a certain location?

Asked by 7 years ago

I have been trying to make this work in a normal script, the code executes the "Moving to #1" print, but it does not actually move the character, and I have no idea why that is. The path to the SpawnPoint is correct.

--Waiting for players to load
while #game.Players:GetPlayers() == 0 do
    wait()
end

--Teleports player to #1
for _, player in pairs(game.Players:GetPlayers()) do    

    --prints out amount of players
    print(#game.Players:GetPlayers())

    local character = player.Character or player.CharacterAdded:Wait()
    local SpawnPoint = game.Workspace.Plots.Plot_1.SpawnPoint

    --If Character is loaded
    if (character) then
        print("Moving to #1")

        --teleports player to SpawnPoint
        character.PrimaryPart.CFrame = SpawnPoint.CFrame
    end     
end

any ideas?

1 answer

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

**Try this **

character.Torso.CFrame = SpawnPoint.CFrame
0
My problem was the fact some of the bricks was not loaded yet. But nevertheless, my problem got solved. Not by this, but I guess this could work aswell. I'll accept your answer. Codegasm 0 — 7y
Ad

Answer this question