Player Isent Teleporting?

When the player dies I want them to spawn at there home spawn, but everything I try doesent work. Please help.

script:

char.Humanoid.Died:Connect(function()
	char.HumanoidRootPart.CFrame = newRoom:WaitForChild("Spawn").CFrame + Vector3.new(0,3,0)
end)

You want to check for when the humanoid spawns, not when they die. You can use CharacterAdded instead, which will fire when the player’s character spawns.

Edit: You can also use char:MoveTo() to move the model instead of using CFrame

1 Like

doesent work. player doesent go to the position.

1 Like

Have you tried using MoveTo()? Also, CharacterAdded is an event of Player, not Humanoid

yes, I have. I have no idea why it isent working.

This is what I did

game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
char:MoveTo(workspace.PlayerRooms:FindFirstChild(player.Name…“Room”).Spawn.Position + Vector3.new(0,3,0))
end)
end)

can you try :SetPrimaryPartCframe instead?

Strange, I just tested it in studio and it works fine if I make it wait for 3 second, but not without a wait

game.Players.PlayerAdded:Connect(function(player)
	print("attatched to player")
	player.CharacterAppearanceLoaded:Connect(function(char)
		print("attatched to character")
		print(char.Name)
		wait(3)
		char:MoveTo(workspace.Part.Position)
	end)
end)

you can try this yourself, I have no idea why it doesn’t work especially since i used CharacterAppearanceLoaded

Edit: What have I done wrong with formatting this, does ``` not end a code block???

Thanks Vercte2 you saved my life

1 Like

Got the solution for your answer!

char.Humanoid.Died:Connect(function()
	char.HumanoidRootPart.CFrame = newRoom:WaitForChild("Spawn").CFrame * Vector3.new(0,3,0)
end)

The operation you’re trying to use is + , so we have to use *.

Add a spawn point. That’s basically it.

Simple solution which may work in this case, do :LoadCharacter on the player once the player dies, and then immediately set the humanoidrootpart cframe to whatever you want, this would work even if the server lagged.

What about Character:SetPrimaryPartCFrame() ?

You should’ve given more info, like what is the error.

This might work:

char.Humanoid.Died:Connect(function()
    repeat wait() until char.Humanoid.Health ~= 0
    wait(3)
	char.HumanoidRootPart.CFrame = CFrame.new(newRoom:WaitForChild("Spawn").Position+ Vector3.new(0,3,0))
end)

However, you could just make a team spawnpoint instead of writing this unnecessary code.

My friend fixed it, thats the solution.