I have a part that lights other parts on fire, and decreases health if the part that touched it belongs to a player.
local firepart = script.Parent
firepart.Transparency = 1
local function LightOnFire(part)
local fire = part:FindFirstChild("Fire")
if not fire then
fire = Instance.new("Fire")
fire.Parent = part
local hum = part.Parent:FindFirstChild("Humanoid")
while fire do
if hum then
hum.Health = hum.Health - 1
end
wait(.50)
end
end
end
firepart.Touched:connect(LightOnFire)
The effect that I want is to decrease the players health by a set value of 1 every 50 milliseconds, but that value adds up for every piece of the player that is on fire.
I'm sure you've noticed another problem. The player still loses health even when the fire is removed. I know, this whole block of code is a mess, now how would these problems be solved? Please keep in mind that I would like for normal parts to catch on fire too.

3 comments
Explain your answer in English. Don't just post code; this doesn't help the poster or the community understand why the code does what it does.
There, I explained it, now can you please stop bossing me around?
https://scriptinghelpers.org is bossing you around, since I GOT THAT SENTENCE FROM THEIR GUIDELINES.