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 9 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 )

01print(player.Name ..tostring(" has joined"))
02 
03repeat wait() until player.Character.Torso
04 
05    if player.Character and player.Character:FindFirstChild("Torso") then
06        local character = player.Character
07 
08        print("Moving character")
09        character.Torso.CFrame = CFrame.new(game.Workspace.Pod1.Podbase.Position + Vector3.new(0,4.5,0))
10        character.Torso.Anchored = true
11 
12        if character.ForceField then
13            character.ForceField:Destroy()
14        end        
15 
16        wait(0.1)
17        script.CameraScript:clone().Parent = character
18 
19    end

end)

1 answer

Log in to vote
0
Answered by 9 years ago

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

Ad

Answer this question