Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

When I made a script to get rid of a fire it works but the fire stays there. What is wrong?

Asked by
Pvzw 19
6 years ago
Edited 6 years ago

So I have a brick with fire in it. I have a hose that shoots out foam that makes the Fire smaller.

local bubble = script.Parent 
bubble.Touched:connect(function(part)
    parts = part:GetChildren()

    for i = 1, #parts do
        if parts[i].className == "Fire" then
            parts[i].Size =parts[i].Size - 0.1
        end
    end
    bubble:remove()
end)

But the fire doesn't disappear yet stays at 2. Then I tried adding if part's fire is less or equal to 2, it will disable the fire.

for i = 1, #parts do
        if parts[i].className == "Fire" then
            parts[i].Size =parts[i].Size - 0.1
            if parts[i].className == "Fire" and parts[i].Fire <= 2 then
            parts[i].Enable = false
        end
    end
end
    bubble:remove()
end)

But it didn't work. What is missing? What is there to change the -0.1 of the size to something other than size? Thank you.

0
Fyi the 2 is the size. Pvzw 19 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

i reviewed your script and replicated it in my studio, the problem is this error:

20:27:20.369 - Fire is not a valid member of Fire
20:27:20.369 - Stack Begin
20:27:20.370 - Script 'Workspace.Bubble.Script', Line 8
20:27:20.371 - Stack End

you are getting that error because parts is the children of part, so its trying to look for a fire inside the fire object. by switching

if parts[i].className == "Fire" and parts[i].Fire.Size <= 2 then

with

if parts[i].className == "Fire" and part.Fire.Size <= 2 then

you should be able to fix the error.

here is the fixed script:

local bubble = script.Parent

bubble.Touched:connect(function(part)
    local parts = part:GetChildren()

    for i = 1, #parts do
        if parts[i].className == "Fire" then
            if part.Fire.Size <= 2 then
                parts[i].Enable = false
            else
                parts[i].Size =parts[i].Size - 0.1
            end
            bubble:remove()
        end
    end
end)

i also made a few adjustments to prevent some problems.

Ad

Answer this question