How to teleport a dead roblox character

Hello! Basically, when the roblox character dies, I want it to teleport back to the spawn point however, teleporting the HumanoidRootPart doesn’t work. I need help!

local folder = script.Parent:GetChildren()
local SpawnFolder = workspace.MainSpawns:GetChildren()
local GetMoney = false

for i, Money in pairs(folder) do
	if Money:IsA("Part") then
		Money.Touched:Connect(function(hit)
			local hum = hit.Parent:FindFirstChild("Humanoid")
			
			if hum then
				local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
				if GetMoney == false then
					GetMoney = true
					plr.leaderstats:WaitForChild("💰 Money").Value += Money.Money.Value
					hit.Parent:WaitForChild("HumanoidRootPart").CFrame = SpawnFolder[math.random(1, #SpawnFolder)].CFrame
					wait(1.3)
					GetMoney = false
				end
			end
			
		end)
		
	end
	
end
1 Like

I think this is mainly because dead players have their joints removed on death, have you tried using PivotTo?

1 Like

No, I haven’t I’ll test it out! How would I set that up though?

It clips the character in the ground, do you know a way around this?

local folder = script.Parent:GetChildren()
local SpawnFolder = workspace.MainSpawns:GetChildren()
local GetMoney = false

for i, Money in pairs(folder) do
	if Money:IsA("Part") then
		Money.Touched:Connect(function(hit)
			local hum = hit.Parent:FindFirstChild("Humanoid")
			
			if hum then
				local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
				if GetMoney == false then
					local char = plr.Character
					local Pivot = char:GetPivot()
					char:PivotTo(SpawnFolder[math.random(1, #SpawnFolder)].CFrame)
					
					GetMoney = true
					plr.leaderstats:WaitForChild("💰 Money").Value += Money.Money.Value
					
					
					--hit.Parent:WaitForChild("HumanoidRootPart").CFrame = SpawnFolder[math.random(1, #SpawnFolder)].CFrame
					wait(1.3)
					GetMoney = false
				end
			end
			
		end)
		
	end
	
end

Do you want to teleport the dead person or their body when they respawn?

1 Like

The dead person.

ExtraCharactertsGoHere

Are you trying to move the corpse?

If so, check out MoveTo

1 Like

So it wouldn’t be PivotTo() like the other person said? Wait no PivotTo() works!

PivotTo() and MoveTo do pretty much the same thing to my knowledge.

1 Like

Oh, I see by the way, thanks so much!

Thanks for the help guys! Thanks so much to these guys @Overseerzed @Asmetics @MichaelTheCat9!

local folder = script.Parent:GetChildren()
local SpawnFolder = workspace.MainSpawns:GetChildren()
local GetMoney = false

for i, Money in pairs(folder) do
	if Money:IsA("Part") then
		Money.Touched:Connect(function(hit)
			local hum = hit.Parent:FindFirstChild("Humanoid")
			
			if hum then
				local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
				if GetMoney == false then
					local char = plr.Character
					local Pivot = char:GetPivot()
					char:PivotTo(Pivot * SpawnFolder[math.random(1, #SpawnFolder)].CFrame)
					
					GetMoney = true
					plr.leaderstats:WaitForChild("💰 Money").Value += Money.Money.Value
					wait(1.3)
					GetMoney = false
				end
			end
			
		end)
		
	end
	
end
1 Like

I’ve actually never used PivotTo() so I’m not sure, MoveTo() just takes the model and moves it somewhere, since all the motor6D’s are destroyed on death as the BreakJointsOnDeath property is set to true you cannot teleport the HumanoidRootPart because none of the other parts are connected to it.

You could use MoveTo() or disable the BreakJointsOnDeath property on the humanoid before it dies via a script in starterCharacterScripts that disables it.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.