You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
As in the title, I want it so a random part would flicker on then off, then moves to the next random part.
What is the issue? Include screenshots / videos if possible!
All of them just turns on but it doesn’t turn back off, and doesn’t appear as fast.
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I couldn’t find anything atm.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
local TweenService = game:GetService("TweenService")
local BarLeft = game.Workspace.BarLeft
local function shuffle(tbl)
for i = #tbl, 2, -1 do
local j = math.random(i)
tbl[i], tbl[j] = tbl[j], tbl[i]
end
end
local function flicker()
while game.Workspace.Contestants.IsPlaying do
local parts = BarLeft:GetChildren()
shuffle(parts)
for _, part in ipairs(parts) do
if tonumber(part.Name) then
TweenService:Create(part, TweenInfo.new(0.2), {Color = Color3.fromRGB(0, 0, 0)}):Play()
task.wait(0.1)
TweenService:Create(part, TweenInfo.new(0.2), {Color = Color3.fromRGB(255, 255, 255)}):Play()
task.wait(0.3)
end
end
end
end
local function onClicked()
for _, part in ipairs(BarLeft:GetChildren()) do
if tonumber(part.Name) then
TweenService:Create(part, TweenInfo.new(0.2), {Color = Color3.fromRGB(0, 0, 0)}):Play()
end
end
flicker()
end
script.Parent.ClickDetector.MouseClick:Connect(onClicked)
Sorry I did read your title, your post and your script, but I dont quite understand what you are trying to achieve.
Indeed the logic inside the script seems not right. Could you elaborate whats the exact behavior you expect?
I bet anything you desire to achieve can be done in a very different way than your script is doing right now. I just need to understand what you are aiming for
Click detector is active, a random part is chosen it will tween from white to black, then picks another random part and does the same, like a flicker effect.
I just re-read the post, I think I found your bug.
Here, you tween them to black first, before tweening them to white.
The task.wait() lines don’t wait as long as the tweens play, meaning the 1st tween is still playing when the 2nd tween starts, and the loop waits an extra .1 seconds before continuing. If you wanted to wait as long as they played, you can do: