No humanoidrootpart in the player character when there is a humanoidrootpart in the player character?

  1. What do you want to achieve?
    I want my players to get teleported to a specific place everytime when they die/reset.

  2. What is the issue?
    Whenever i die it tells me that i don’t have a HumanoidRootPart when my character has one

  3. What solutions have you tried so far?
    I tried adding a :WaitForChild() but i got an infinite yield, I also tried changing it from R15 to R6, still the same errors, i got into the server and the server has the humanoidrootpart inside my character

–[[

Infinite yield possible on 'Workspace.Steven_Rafft:WaitForChild("HumanoidRootPart")'

]]–
Heres what i have in my script

game.Players.PlayerAdded:Connect(function(plr)
	if game.ServerStorage.GameStarted.Value == true then
		for i, v in pairs(workspace:GetChildren()) do
			if v.Name == plr.Name then
				v.HumanoidRootPart.CFrame = workspace.map.SpawnArea.CFrame
			end
		end
	end
	
	workspace:WaitForChild(plr.Name).Humanoid.Died:Connect(function()
		workspace[plr.Name]:WaitForChild("HumanoidRootPart")
		workspace[plr.Name].HumanoidRootPart.CFrame = workspace.map.SpawnArea.CFrame
	end)
	
end)

This is extremely confusing since there is an humanoidrootpart in the player character, it’s like only the client has an instance of the humanoidrootpart

1 Like

This code is badly organized and I believe that you are trying to set the humanoid root part position of a dead humanoid. Why not use Player.CharacterAdded instead of Humanoid.Died?

3 Likes

I can agree with you because he’s trying to move a dead humanoid

1 Like

Whenever a player joins it also does it aswell is there something to make it not do that?

Use an if statement to check for wanted conditions.

1 Like

Ah great idea, will try it thanks.

– Here is your solution; very simple and quick. I would be apperciated if you pin this reply as your solution –

local SpawnLocation = game.Workspace[“Type you spawn location’s name here”]

game.Players.PlayerAdded:Connect(function(plr) – This is the player
plr.CharacterAdded:Connect(function(char) – This is the player’s character which includes HumanoidRootPart
char:FindFirstChild(“HumanoidRootPart”).CFrame = CFrame.new(SpawnLocation.Position) – Teleports the player when his character is added
end)
end)

1 Like

Thanks for the answer but @Weldify told me how to fix it aswell so you both have the solution. I have forgotten about the CharacterAdded function, haven’t used it in a while.