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

Why doesn't the player teleport when he dies?

Asked by 10 years ago
game.Players.PlayerAdded:connect(function(player)
    player.CharacterAdded:connect(function(character)
local spawns = mapChosenClone.Spawns:GetChildren()
    for i,v in pairs(game.Players:GetPlayers()) do --Problem
        local name = v.Name
        local check = game.Workspace:FindFirstChild(name)
        if check then
            local checkHumanoid = check:FindFirstChild("Humanoid")
            if checkHumanoid then
                check:MoveTo(spawns[i].Position)
                end
            end
        end
    end)
end)

When the player respawns the player doesn't teleport. I'm pretty sure its the line where I put the comment. This is probably a stupid mistake but I forget things.

3 answers

Log in to vote
0
Answered by 10 years ago

Please do not hate me if this does not work p.p

game.Players.PlayerAdded:connect(function(player)
    player.CharacterAdded:connect(function(character)
local spawns = mapChosenClone.Spawns:GetChildren()
    for i,v in pairs(game.Players:GetPlayers()) do --Problem
        local name = v.Name
        local check = game.Workspace:FindFirstChild(name)
        if check then
            local checkHumanoid = check:FindFirstChild("Humanoid")
            if checkHumanoid then
                check.Parent.Torso.CFrame  =  CFrame.new(spawns[i].Position)
                end
            end
        end
    end)
end)
0
at least you tried and didn't just copy the script and do nothing rabidhalofan12345 55 — 10y
Ad
Log in to vote
-1
Answered by 10 years ago

Because move to makes the humanoid 'walk to the position'. Set the CFrame of the torso.

Log in to vote
-2
Answered by 10 years ago
game.Players.PlayerAdded:connect(function(player)
    player.CharacterAdded:connect(function(character)
local spawn = mapChosenClone.Spawns:GetChildren()
    for i,v in pairs(game.Players:GetPlayers()) do --Problem
        local name = v.Name
        local check = game.Workspace:FindFirstChild(name)
        if check then
            local checkHumanoid = check:FindFirstChild("Humanoid")
            if checkHumanoid then
                check:MoveTo(spawns[i].Position)
                end
            end
        end
    end)
end)

Hopefully this should work!

0
you changed nothing you just copied the script and pasted it back rabidhalofan12345 55 — 10y
0
spawns to spawn iDoctorW 0 — 10y

Answer this question