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

Children and Effects (?)

Asked by 3 years ago

I have a model with various parts. Each one of them has a smoke effect.

Img

I have a script in which i want to enable and disable all of them at once.

How can i do this?

1 answer

Log in to vote
0
Answered by
rabbi99 714 Moderation Voter
3 years ago

I recently discovered a useful trick to change data of the children or descendants. It will be useful in your case too. You gotta put this script in your model. It goes like this:

local parts = script.Parent:GetDescendants()

function DisableSmoke()
    for i,v in pairs(parts) do
        if v:IsA("Smoke") then
            v.Enabled = false
        end
    end
end

DisableSmoke()

I will let you do the enable part yourself, because you'll learn from it.

0
Thanks, i knew there was something to check if a item was "X" but i forgot what. And this reminded me. Thanks! izan2000 2 — 3y
0
:GetDescendants() will be quite useful to me in the future lol! Clorize 31 — 3y
Ad

Answer this question