ProximityPrompt wont enable when humanoid health is <= 20

I have a gun and when the gun shoots it takes away 1 health (which it does and its 21 health) however, when I try to make it where once it becomes 20, it shows the prompt, I have an NPC in the NPCS folder named Max, and I put a SERVER script inside it so prox prompt would enable, however it didnt. heres the script

local Max = game.Workspace.NPCs.Max
local Humanoid = Max.Humanoid
local Prompt = Max.PourLiquid
local player = game.Players.LocalPlayer


if Humanoid.Health <= 20 then
	Prompt.Enabled = true
end

Thank you for your time!

3 Likes

That code only checks the statement once and not multiple times. Try using health.changed or health:GetPropetyChangedSignal(“Health”)

2 Likes

like this?

if Humanoid.HealthChanged <= 20 then
	Prompt.Enabled = true
end
2 Likes

wait that would give me an error lol

2 Likes

Try
Humanoid:GetPropertyChangedSignal(“Health”):Connect(function()
— check health then if true do what you want it to do
end)

2 Likes

Lol yeah, I did notice you didn’t connect it or whatever but the code I sent in another post is probably better because the event will only fire if it’s the health that changes and not everything.

2 Likes

Yeah lol It worked! Thank you so much!

You’re welcome! Happy developing!

1 Like

still kinda new to scripting so I had no idea what that was! Ive been gaining alot of knowledge but now I have that in my dictionary

Ah, alrighty. Hopefully this can help you with future things.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.