function UTIL.WaitForValidCharacter(K)local r=K.Character if not r or not r.Parent or not r:FindFirstChild("\072\117\109\097\110\111\105\100")or r.Humanoid.Health<=0 then K.CharacterAdded:Wait()wait()r=K.Character end return r 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()
		character = player.Character
	end
	return character
end
