How to spread "Douse" to ALL parts of player if one part touches?

My “Douse” script currently removes fire from any humanoid part that touches the part with the Douse Script. How can I adjust the script so that fire goes out on ALL parts of the humanoid if one part touches the Douse block?

Here’s my current script:

local waterPart = script.Parent

local function putOutFire(part)
	local Fire = part:FindFirstChild("Fire") 
	if Fire then 
		Fire:Remove()
	end
end

waterPart.Touched:Connect(putOutFireA)

If you want to remove all of a certain instance’s descendants of a type you would do this:

local function putOutFire(part)
    assert(typeof(part) == "Instance","Error part is not and instance")
    for index, descendant in pairs(part:GetDescendants()) do
        if descendant:IsA("Fire") then
            descendant:Destroy()
        end
    end
end
1 Like

Thanks for the help!
I didn’t think this would matter, but it does apparently. I have two fire types, and I’m trying to do this for type “FireA.” I dropped in your function and changed “Fire” to “FireA” but I must have done that wrong because it says “FireA is an unknown type” in the line “if descendant:IsA(“FireA”) then.” Here’s what I have:

local waterPart = script.Parent

local function putOutFireA(part) 
	local FireA = part:FindFirstChild("FireA") 
	assert(typeof(part) == "Instance","Error part is not and instance")
	for index, descendant in pairs(part:GetDescendants()) do
		if descendant:IsA("FireA") then
               descendant:Destroy()
		end
	end
end

waterPart.Touched:Connect(putOutFireA)

:IsA is a function that checks the classname of the object. if you want it to check for something that is named fire vs something named fireA, change the check to

if descendant.Name == "FireA" then 
--destroy
end
1 Like

If you want to remove the FireA, change descendant:IsA("FireA") to descendant.Name == "FireA", the :IsA("Fire") checks if the thing is a fire instance, even if its name is different, so use the name one.

1 Like

Ok. I’ll give that a go. Thanks!
But it sounds like it will remove the other fire type as well (just called “Fire” per norm). If that’s the case, is there a way to do it so that I do not remove “Fire” instances and only remove “FireA” instances?

You have to check for it’s name instead of the :IsA() function

1 Like

That worked! Thanks so much for all the help!
I noticed that it doesn’t seem to go through the whole model, rather, work it’s way down from the touched part, but it’s WAY better than what I had before and does the job since usually the foot was still on fire. :slight_smile: Thanks again!

Now I just have to figure out how to douse the attached Parachute Tool at the same time. It’s pretty funny at the moment though… PC catches fire by parachuting through power lines, then cools off post parachute by running to the pool. But if the user opens the parachute tool again, BAM, it’s on fire still! :smiley:

Thanks! Will give this a try! I’m new to scripting and appreciate the help.

Try this, it might work for you since it only removes FireA

local waterPart = script.Parent

local function putOutFireA(part) 
	assert(typeof(part) == "Instance","Error part is not and instance")
	for index, descendant in pairs(part:GetDescendants()) do
		if descendant.Name == "FireA" then
               descendant:Destroy()
		end
	end
end

waterPart.Touched:Connect(putOutFireA)
1 Like