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

Why does this work in single player but not when published?

Asked by 8 years ago

I am mid way through creating some code which teleports a player (using torso CFrame) when they join the game, the code works fine in single player mode (Test mode) however it does not seem to move the player, the code after it is executed because the player is frozen in the air. I have tried adding a wait before the CFrame move movement but it don't seem to work. Here is the code:

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

print(player.Name ..tostring(" has joined"))

repeat wait() until player.Character.Torso

    if player.Character and player.Character:FindFirstChild("Torso") then
        local character = player.Character

        print("Moving character")
        character.Torso.CFrame = CFrame.new(game.Workspace.Pod1.Podbase.Position + Vector3.new(0,4.5,0))
        character.Torso.Anchored = true

        if character.ForceField then
            character.ForceField:Destroy()
        end         

        wait(0.1)
        script.CameraScript:clone().Parent = character

    end

end)

1 answer

Log in to vote
0
Answered by 8 years ago

Have been checking the wiki, cant seem to find any solutions...

Ad

Answer this question