-
What do you want to achieve? Keep it simple and clear!
I want to change the material of objects and tween their color. One group of objects share one tag and the other group share a different tag. I use “GetTagged” and “for i, v do” to find and seperate each group. Then, here is where I am stuck, I want to create a table for each group and put those tables inside another, just to keep it organized. but idk if it helps my script to do all that. -
What is the issue? Include screenshots / videos if possible!
The issue is that once I define the tables and put them inside a single table, when I try to change the properties of the parts inside each group as a whole using a tween, it only tweens the first object inside each table, not every part inside each table. -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I have already made the tables for each group and put them in a single table, but like I said, once I try to change the material and tween the color only the first part inside each table is found. I want to change the material and tween the parts of each of the two tables inside the main table. (HOPE THIS MAKES SENSE, SORRY).
Here is my original script that works and does what I want, WITHOUT THE TABLES.
local TweenService = game:GetService("TweenService")
local CollectionService = game:GetService("CollectionService")
local Button2 = script.Parent["Lights 1 Fuscia"]
local TweenInfo = TweenInfo.new(
1, --number of seconds
Enum.EasingStyle.Linear, --how it moves
Enum.EasingDirection.InOut, --how it moves
-1, --how many times to repeat
true, --go back to start after ending?
0 --the wait before starting
)
local Color = {
{Color = Color3.new(0.666667, 0, 0)},
{Color = Color3.new(0.333333, 0, 1)}
}
for i,LightBulbsGroup1 in pairs(CollectionService:GetTagged("Mainstage Backdrop Lightbulb Lights Alternating Pattern Group 1")) do
for i,LightBulbsGroup2 in pairs(CollectionService:GetTagged("Mainstage Backdrop Lightbulb Lights Alternating Pattern Group 2")) do
Button2.MouseButton1Click:Connect(function()
LightBulbsGroup1.Material = Enum.Material.Neon
TweenService:Create(LightBulbsGroup1, TweenInfo, Color[1]):Play()
task.wait(1)
LightBulbsGroup2.Material = Enum.Material.Neon
TweenService:Create(LightBulbsGroup2, TweenInfo, Color[2]):Play()
task.wait(1)
end)
end
end
Here is how this looks in game.
And here is what I have tried to do, but like I mentioned it only find the first part inside each of the tables, and I want to be able to change the properties of each entire table!
local TweenService = game:GetService("TweenService")
local CollectionService = game:GetService("CollectionService")
local Button2 = script.Parent["Lights 1 Fuscia"]
local TweenInfo = TweenInfo.new(
1, --number of seconds
Enum.EasingStyle.Linear, --how it moves
Enum.EasingDirection.InOut, --how it moves
-1, --how many times to repeat
true, --go back to start after ending?
0 --the wait before starting
)
local Color = {
{Color = Color3.new(0.666667, 0, 0)},
{Color = Color3.new(0.333333, 0, 1)}
}
local Light = {}
for i,LightBulbsGroup1 in pairs(CollectionService:GetTagged("Mainstage Backdrop Lightbulb Lights Alternating Pattern Group 1")) do
table.insert(Light,LightBulbsGroup1)
for i,LightBulbsGroup2 in pairs(CollectionService:GetTagged("Mainstage Backdrop Lightbulb Lights Alternating Pattern Group 2")) do
table.insert(Light,LightBulbsGroup2)
Button2.MouseButton1Click:Connect(function()
Light[1].Material = Enum.Material.Neon
TweenService:Create(Light[1], TweenInfo, Color[1]):Play()
task.wait(1)
Light[2].Material = Enum.Material.Neon
TweenService:Create(Light[2], TweenInfo, Color[2]):Play()
task.wait(1)
end)
end
end
Video showing what I mean