I’ve been stuck on this issue for the past hour so far and looked through solutions but still can’t seem to fix this error, so I have a error for my movement system which works perfectly fine but when the player dies then it breaks, I’ve dumbed it down to this area where it is not getting the new character and humanoid because my script checks for the humanoid health and it keeps saying 0 even when i respawn, is there any better way I can check for when the player respawns to set their new character and health?
local MovementController = nil
if Player then
print("yo")
local char = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()
if char then
Player = game.Players.LocalPlayer
Character = char
Humanoid = char:FindFirstChild("Humanoid")
MovementController = MovementManager.New(game.Players.LocalPlayer)
MovementController:OnSpawn()
Humanoid.Died:Connect(function()
MovementController:OnDeath()
end)
end
end