This is a really simple script that I think doesn't work because if statements don't update all the time, but I don't know how to make it so it does. Please help if you do.
if script.Parent.Humanoid.Health <= 50 then script.Parent.Torso.ParticleEmitter.Enabled = true end
What you should do is use an event called HealthChanged. HealthChange is an event from the Humanoid that detects whenever the health of the humanoid, well, changes.
local humanoid = script.Parent.Humanoid --Assign an event humanoid.HealthChanged:Connect(function(newHealth) if newHealth <= 50 then script.Parent.Torso.ParticleEmitter.Enabled = true else script.Parent.Torso.ParticleEmitter.Enabled = false end end)
What the script does is that whenever the health of the humanoid changes, it detects whether if the health is lower than 50, it it is, it will enable the particle emmiter. I also assume that once the humanoid's health is greater than 50, you would want the particle emitter to disable itself, but if you don't want it to, just delete the else part of the if-statement.
you just showed three lines of code so i am assuming that you forgot to constantly check for if the health is below 50
if script.Parent.Humanoid.Health <= 50 then script.Parent.Torso.ParticleEmitter.Enabled = true end
if you just put these lines of code the game will only check once and doesnt run more than once
use a while true do or run service
while wait() do --if health is below 50 --checks every 1/30 of a second end
run service
local RunService = game:GetService("RunService") RunService.Heartbeat:Connect(function() --checks every single frame if health is below 50 end)