-- Waits for a new character to be added if the current one is invalid
-- (Ensures that you don't have the old dead character after a respawn)

function UTIL.WaitForValidCharacter(player)
	local character = player.Character
	if not character or not character.Parent or not character:FindFirstChild('Humanoid') or character.Humanoid.Health <= 0 then
		player.CharacterAdded:Wait()
		wait()
		character = player.Character
	end
	return character
end

