✓ Accepted answer
For this, I recommend the use of coroutines
Coroutines create a separate thread where you can run your loops without disturbing the flow of your main script.
There are 2 key functions that you require: coroutine.resume(c) - c being a created coroutine coroutine.create(f) - f being a function
You must create a coroutine before using it (by calling resume()) There are a couple of ways of making a coroutine, I will show you one.
coroutine.resume(coroutine.create(function()
end))
So, for you it should go like this:
local Epic=script.Parent.ClickDetector
function onClick()
for i,v in pairs(game.Workspace.Model:GetChildren()) do
coroutine.resume(coroutine.create(function()
for i = 0, 1, 0.1 do
v.Transparency = 1 - i
wait(0.1)
end
end))
end
end
Epic.MouseClick:connect(onClick)
Hopefully that should work for you now
2 comments
This is because for loops only work on one task at a time, it won't do it all at once.
This is because for loops only work on one task at a time, it won't do it all at once.