Why does this work in single player but not when published?
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 )
01 | print (player.Name .. tostring ( " has joined" )) |
03 | repeat wait() until player.Character.Torso |
05 | if player.Character and player.Character:FindFirstChild( "Torso" ) then |
06 | local character = player.Character |
08 | print ( "Moving character" ) |
09 | character.Torso.CFrame = CFrame.new(game.Workspace.Pod 1. Podbase.Position + Vector 3. new( 0 , 4.5 , 0 )) |
10 | character.Torso.Anchored = true |
12 | if character.ForceField then |
13 | character.ForceField:Destroy() |
17 | script.CameraScript:clone().Parent = character |
end)