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!
GetInstanceEffect where it will tween from 1 to 52
What is the issue? Include screenshots / videos if possible!
Explained above, when I click the button its meant to tween from 1 to 52, but it starts at a random part than 1 to 52, like it would do it backwards instead of counting up.
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")
-- Function to tween color
local function tweenColor(part, endColor, duration)
local tweenInfo = TweenInfo.new(duration, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut)
local tween = TweenService:Create(part, tweenInfo, {Color = endColor})
tween:Play()
end
-- Get the model and its parts
local model = game.Workspace.Neons
local function onClicked()
local parts = model:GetChildren()
for i = 1, 52 do
local part = parts[i]
if part and part:IsA("BasePart") then
tweenColor(part, Color3.fromRGB(170, 170, 255), 1)
wait(1)
end
end
end
script.Parent.ClickDetector.MouseClick:Connect(onClicked)
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.
local function onClicked()
local parts = model:GetChildren()
for i, part in pairs(parts) do
if part and part:IsA("BasePart") then
tweenColor(part, Color3.fromRGB(170, 170, 255), 1)
wait(1)
end
end
end
Feel free to ask me anything if u need !
I hope it helped and have a nice day !
EDIT : oops im stupid as always it will not work with my solution since it will be random … sorry
No worries; instead of using FindFirstChild which only returns 1 object at a time, we can loop through the model and tween the parts named i.
Like this:
for i = 1, 52 do
for _, part in ipairs(model:GetChildren()) do
if part.Name == tostring(i) then
tweenColor(part, Color3.fromRGB(170, 170, 255), 1)
end
end)
task.wait(1) -- change if you want idk
end
Edit: Replaced pairs with ipairs, and changed i2 to _, as per PhoenixRessusection’s more suitable suggestion
There are multiple parts with the same name (eg multiple parts named “1”), so FindFirstChild will only return one of those parts; the rest are skipped.
The loop ensures all parts with the relevant index as their name are tweened.