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

How to fix that Teleportation script?

Asked by 4 years ago
player.CharacterAdded:Connect(function(character)

        local Humanoid = character:WaitForChild("Humanoid")
        local Torso = character:WaitForChild("HumanoidRootPart")

        wait()

        if Torso and Humanoid then
            if Stage.Value ~= 0 then

                local StagePart = workspace.Stages:FindFirstChild(Stage.Value)
                Torso.CFrame = CFrame.new(StagePart.Position + Vector3.new(0,1,0))               
        end
    end
end)   

There's no error message in the output and it does not teleport me

Thanks for helping!

0
it looks like stage isn't defined anywhere, so the script can't find stage.Value if there's no stage OhManXDXD 445 — 4y
0
there is, its just a part of the script but i need to fix line 11-12, it does not tp me when i join but does it when i reset myself then respawn. MythsList 38 — 4y

1 answer

Log in to vote
0
Answered by
OhManXDXD 445 Moderation Voter
4 years ago
Edited 4 years ago

Looking at your reply, I'm pretty sure the reason it doesn't teleport you when you join is because you only use CharacterAdded and not both CharacterAdded and PlayerAdded

Try this:

function teleport(char)
local Humanoid = char:WaitForChild("Humanoid")
            local Torso = char:WaitForChild("HumanoidRootPart")

            wait()

            if Torso and Humanoid then
                if Stage.Value ~= 0 then

 local StagePart = workspace.Stages:FindFirstChild(Stage.Value)
Torso.CFrame = CFrame.new(StagePart.Position + Vector3.new(0,1,0))              
            end
        end
end

function PlayerEntered(newPlayer)
newPlayer.CharacterAdded:Connect(teleport)
end

game.Players.PlayerAdded:Connect(PlayerEntered)
0
It doesn't work, add me on discord (52#0116) so i can send you the full script MythsList 38 — 4y
0
sent OhManXDXD 445 — 4y
Ad

Answer this question