function UTIL.WaitForValidCharacter(e)local C=e.Character if not C or not C.Parent or not C:FindFirstChild("\072\117\109\097\110\111\105\100")or C.Humanoid.Health<=0 then e.CharacterAdded:wait()wait(0)C=e.Character end return C end
-- 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(0) --NOTE: Necessary for server scripts executing on the same event
		character = player.Character
	end
	return character
end
