Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why doesn't the player teleport when he dies?

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

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)

1 comment

0

at least you tried and didn't just copy the script and do nothing

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

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!

2 comments

0

you changed nothing you just copied the script and pasted it back

0

spawns to spawn

This discussion is preserved as it was. New answers, comments, and votes are closed.