-
What do you want to achieve? Keep it simple and clear!
I’m trying to make a lighting system that changes the color of every part In a folder at the same time, everything works. -
What is the issue? Include screenshots / videos if possible!
The tweens are “taking turns” on each part/union. So it goes to one first, then another, and another, so another. This is extremely inefficient and I thought this was gonna be efficient… -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I’ve tried some different tween methods but nothing seems to really work any better.
Script:
local tweenservice = game:GetService("TweenService")
local info = TweenInfo.new(0.5, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, false, 0)
game.ReplicatedStorage.ColorChangerEvents.Change.OnServerEvent:Connect(function(plr, r, g, b, stafflock, groupid, minRank)
print(r, g, b)
local selColor = Color3.fromRGB(r, g, b)
print(selColor)
if stafflock == true then
if plr:GetRankInGroup(groupid) >= minRank then
for i,v in pairs(game.Workspace.ChangingParts:GetDescendants()) do
if v:IsA("BasePart") then
local tween2 = tweenservice:Create(v, info, {Color = Color3.fromRGB(0, 0, 0)})
tween2:Play()
wait(0.5)
local tween = tweenservice:Create(v, info, {Color = selColor})
tween:Play()
end
end
for i,v in pairs(game.Workspace.ChangingParts:GetDescendants()) do
if v:IsA("UnionOperation") then
v.UsePartColor = true
local tween2 = tweenservice:Create(v, info, {Color = Color3.fromRGB(0, 0, 0)})
tween2:Play()
wait(0.5)
local tween = tweenservice:Create(v, info, {Color = selColor})
tween:Play()
end
end
end
else
for i,v in pairs(game.Workspace.ChangingParts:GetDescendants()) do
if v:IsA("BasePart") then
local tween2 = tweenservice:Create(v, info, {Color = Color3.fromRGB(0, 0, 0)})
tween2:Play()
wait(0.5)
local tween = tweenservice:Create(v, info, {Color = selColor})
tween:Play()
end
end
for i,v in pairs(game.Workspace.ChangingParts:GetDescendants()) do
if v:IsA("UnionOperation") then
v.UsePartColor = true
local tween2 = tweenservice:Create(v, info, {Color = Color3.fromRGB(0, 0, 0)})
tween2:Play()
wait(0.5)
local tween = tweenservice:Create(v, info, {Color = selColor})
tween:Play()
end
end
end
end)
(Yes the event is fired from a local script the player activated with the gui.)
Video of how it’s currently working: