I keep getting an infinite yield on my HumanoidRootPart. This is inside a UI, and I don’t want ResetOnSpawn set to true, as it takes a while for the UI to load all elements, and so would have to reload all the elements again after death (I left all that out of the code below)
return function()
local Character = Player.Character or Player.CharacterAdded:Wait()
local HumanoidRootPart = Character:WaitForChild('HumanoidRootPart')
-- New character
local function NewCharacter()
Character = Player.Character or Player.CharacterAdded:Wait()
HumanoidRootPart = Character:WaitForChild('HumanoidRootPart') -- Infinite yield
end
Character.Humanoid.Died:Connect(NewCharacter)
end