Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Please can someone help with variables?

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()

1 comment

2

You cannot assign two things to one variable. You can create an array though and assign each element within that array.

2 answers

✓ Accepted answer

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

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()

2 comments

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

0

You could try doing what Necrorave said. That could work out for you.

This discussion is preserved as it was. New answers, comments, and votes are closed.