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

I want this function to stop distributing fire if a person is already on fire?

Asked by 7 years ago
Edited 7 years ago
function onTouch(part)
    Fire=Instance.new("Fire")
    Fire.Parent=part
    fire=part:FindFirstChild("Fire") 
        if fire then Fire:Destroy()  --Line I need help with and also have the function not do anything.
        end
end
a=game.Workspace.FirePart
a.Touched:connect(onTouch)

Here is a basic script from the Roblox site that I wanted to change a little.

If you look at the function onTouch, towards the end where it says if fire is there then have the block not do anything end. However, I do not know how to do that.

0
Can you reword the question a bit? It's kind of hard to understand what you're asking. antonio6643 426 — 7y

1 answer

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

Although what you are doing may work the fire would be created regardless of whether there is already a fire in the part because the lines to create your fire is outside the if statement. If you want the script to check the part for fire before creating anything as you've described you want something like this:

function onTouch(Part)
    if not Part:FindFirstChild("Fire") then
        --Create the fire in the part.
    end
end

The if statement will check the part and if the part does NOT have a fire it will run the block. If it does have the fire the block will skip entirely and no fire will spawn.

Ad

Answer this question