Trying to cause immortality via Proximity Prompt

Hi, I’ll get straight to the point.
I’m trying to cause Immortality/Infinite Health upon Triggering a Proximity Prompt, or “Eating a pill.”
I’m not sure what the problem is.

Here’s what I’ve got so far.

local pill = script.Parent.Parent

	-- I don't know if I can reference the player using ^ that

	local Health = player.Character:WaitForChild("Humanoid").Health
	local MaxHealth = player.Character:WaitForChild("Humanoid").MaxHealth
	-- Setting the health to Infinite
	MaxHealth = math.huge
	Health = math.huge
-- Making sure the health is set to Infinite.

I have many speculations, most of which hadn’t worked as I’ve tried setting health to one billion instead of infinite, using FindFirstChild instead of WaitForChild, Referencing the player in a different way.
But no matter what the health never changes. ( I have a strong feeling I’m not referencing the player right.)

1 Like

Ah, I see. We’ve all been there. It doesn’t work because you’re not referencing the player’s health, but instead changing the variable itself to math.huge, and not health. Instead, make a variable for the humanoid and do:

Humanoid.MaxHealth = math.huge
Humanoid.Health = math.huge

I’m not sure this would make you immortal, though, as you could still be killed if your health is changed to 0.

If you want to make the player immortal when their health is set to 0, you could check if the player has some kind of immortality boolvalue, and not kill them.

1 Like

Thanks, this fix worked wonders.

1 Like