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
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
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
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.