This script that should put someone somewhere at the start, is not working

Before you say use a spawn location let me get you up to speed.

I basically have a level game and each level have a spawn point.

So when you when die in one level you went to another.

I then fixed that.

So now I need to make sure that they spawn at level 1.

So I made this script.

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Wait()
	print("waited")
	player.Character:WaitForChild("HumanoidRootPart").CFrame = game.workspace.Lobby.InvisiblePart.CFrame
	print("Done!")
end)

It doesn’t work.

It prints the statements and has no error.

Maybe try like this:

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Wait()
	print("waited")
	player.Character:MoveTo(game.workspace.Lobby.InvisiblePart.Position)
	print("Done!")
end)

You need to yield a bit to overide the default spawn system. As seen from the documentation on character added:

wait() or stepped wait should work.

1 Like

Try this:

game.Players.PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:Connect(function(char)
        char:WaitForChild("HumanoidRootPart").CFrame = game.Workspace.Lobby.InvisiblePart.CFrame
    end)
end)

That has not worked.

It prints and no errors.

This also does not work.

It has no errors.

Add a print after you tp the player?

Edit: nvm theres already a solution

1 Like

This works but how could you make so it only does it when you 1st spawn in the game and not when you die?

If anyone has another solution that would be nice.

You haven’t even tried adding a yield to your script yet?

local part = script.Parent

game.Players.PlayerAdded:Connect(function(player)
	local char = player.Character or player.CharacterAdded:Wait()
	wait()--any yield should do
	char.HumanoidRootPart.CFrame = part.CFrame
end)
2 Likes