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

Please can someone help with variables?

Asked by
traigla 75
9 years ago

I'm trying to get the children of two models into 1 variable, I tried this, but won't work. Any help?

reds1 = elfins.ElfinFlower1.Lights.Red1:getChildren() and elfins.ElfinFlower2.Lights.Red1:getChildren()
2
You cannot assign two things to one variable. You can create an array though and assign each element within that array. Necrorave 560 — 9y

2 answers

Log in to vote
2
Answered by 9 years ago

You can assign each child to a single array with this script

local flowerCount = 2 -- If you have more flowers, change this.
local reds1 = {}

for i = 1, flowerCount do
    for _,v in pairs(elfins["ElfinFlower"..tostring(i)].Lights.Red1:GetChildren()) do
        table.insert(reds1, v)
    end
end

Or, after reading your comment on Spongocardo's answer, you can

--Change:
        table.insert(reds1, v)
--To:
        v.SurfaceGui.Enabled = true
Ad
Log in to vote
0
Answered by 9 years ago

You can't use "and" when assigning a variable, you have to assign separate variables to each value.

red1_1 = elfins.ElfinFlower1.Lights.Red1:GetChildren()
red1_2 = elfins.ElfinFlower2.Lights.Red1:GetChildren()
0
What about this, how can I get both variables in the same loop? for _,v in ipairs (reds1) do v.SurfaceGui.Enabled = true end traigla 75 — 9y
0
You could try doing what Necrorave said. That could work out for you. Spongocardo 1991 — 9y

Answer this question