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

Making a code that makes 2 parts set fire when a cylinder is touched, only one is on fire. Any help?

Asked by 3 years ago
local cylinder = script.Parent
local bomb = game.Workspace.Wedge1
local tsar = game.Workspace.Wedge2
local fireOn = Instance.new("Fire")

--when something is touched, it will set tsar and bomba on fire (not sure what the parameter is for, followed a tutorial)
local function exploder(guythattouchedthecylinder)

--not sure what this is for either, i know that the variable is referring to the parent of the parameter, but dont understand what it really does or how it knows that the parameter is referring to the player or humanoid that touched
    local master = guythattouchedthecylinder.Parent

    --searching for humanoid parts
    local humanoid = master:FindFirstChildWhichIsA("Humanoid")

    --if there is, then tsar and bomba will have a new fire instance
    if humanoid then
        fireOn.Size = 10
        fireOn.Parent = tsar
        fireOn.Parent = bomb
    end

end

--when cylinder is touched, function will fire
cylinder.Touched:Connect(exploder)

The problem here is that only the tsar variable is on fire, so my best bet is that there can be only one parent to the fireOn variable, which is the first. Don't know how to make it have multiple parents, though.

I'd also be happy to receive some advice regarding this code.

1 answer

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

It's because you only make one fire instance. (Line 04) but you attempted to parent that one fire to two parts (Line 18 - 19). So try making two fires instead of one.

local cylinder = script.Parent
local bomb = game.Workspace.Wedge1
local tsar = game.Workspace.Wedge2

--when something is touched, it will set tsar and bomba on fire (not sure what the parameter is for, followed a tutorial)
local function exploder(guythattouchedthecylinder)
    local fire1 = Instance.new("Fire") --creates first fire
    local fire2 = Instance.new("Fire") --creates second fire


--not sure what this is for either, i know that the variable is referring to the parent of the parameter, but dont understand what it really does or how it knows that the parameter is referring to the player or humanoid that touched
    local master = guythattouchedthecylinder.Parent

    --searching for humanoid parts
    local humanoid = master:FindFirstChildWhichIsA("Humanoid")

    --if there is, then tsar and bomba will have a new fire instance
    if humanoid then
        fire1.Size = 10
        fire2.Size = 10
        fire1.Parent = tsar
        fire2 .Parent = bomb
    end

end

--when cylinder is touched, function will fire
cylinder.Touched:Connect(exploder)

Some may argue that it is also doable with table and loops and stuff but I want to keep it as basic as possible so you can actually understand what was the root of the problem. I hope you learned something!

0
damn, so it really was that simple. Thanks for the answer tho zakynthos1 2 — 3y
Ad

Answer this question