Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Part destroys NPC instead of removing fire instances, how to fix?

So I made a script for a liquid, the liquid is supposed to remove all fire instances from the NPC, but for some reason, it just deletes the NPC itself.

The way it works is that the player presses a button, and then the liquid fills up the room that the NPC is in with the help of tweenservice.

This is the script for the liquid:

function putFireOut()
	
	local NPC = workspace.Lab.AIButton.Subject
	
	local getFire = NPC:GetDescendants()
	
	for i,getFire in pairs (getFire) do
		
		if getFire:FindFirstChild("Fire") then
			
			getFire:Destroy()
			
		end
	end
end

local coolerLiquid = workspace.Lab.AIButton.CoolerLiquid
coolerLiquid.Touched:Connect(putFireOut)

Any help would be appreciated

1 comment

0

But you can clear it by using the function :Clear() heres a guide https://developer.roblox.com/en-us/api-reference/function/ParticleEmitter/Clear

1 answer

✓ Accepted answer

Try the code:

local function putFireOut()

    local NPC = workspace.Lab.AIButton.Subject

    local getFire = NPC:GetDescendants()

    for i,getFire in pairs (getFire) do

        if v:FindFirstChild("Fire") then

            v:Destroy()

        end
    end
end

local coolerLiquid = workspace.Lab.AIButton.CoolerLiquid
coolerLiquid.Touched:Connect(putFireOut)

This discussion is preserved as it was. New answers, comments, and votes are closed.