local function action(Pick, part, OldFrame, OldSize) if Pick == 1 then for i = 1, 4 do part.Parent:SetPrimaryPartCFrame(part.CFrame + part.CFrame.UpVector * 2) wait(0.1) part.Parent:SetPrimaryPartCFrame(part.CFrame - part.CFrame.UpVector * 2) wait(0.1) end for i = 1, 20 do part.Parent:SetPrimaryPartCFrame(part.CFrame - part.CFrame.UpVector * 5) wait(0.05) end wait(3) part.Parent:SetPrimaryPartCFrame(OldFrame) end end while wait(1) do local index = math.random(1, #script.Parent.Grounds:GetChildren()) for i, v in script.Parent.Grounds:GetChildren() do if i == index then action(math.random(1, 2), v.Block, v.Block.CFrame, v.Block.Size) print('done') end end end
This is supposed to make different tiles in a little grid go down. How can I make it so it doesn't have to stop until one if finished in order to start another
Well, you added wait() in your while loop, which you have to, but you i think you can use another type of loop, for i loop, like this:
for i = 1, 10 do -- 10 is the amount of times we will repeat this code print("banana!") end
You can try something like that, there is no wait()
so it should fire the print()
function 10 times instantly.
Tho, If you mean that after firing the function it waits before firing it again, that's because your "action" function has wait() inside of it, so it will still yield the script.
You can try using while true do
is a good way to repeat make sure you add wait(.2)
Example
while true do wait() blank --put your code you want to repeat ---- --- wait(.2)
Is this what your wanting?? Hope this helps!!
Alr. So what I wanted from this script is to trigger a function and work like a remote event. Just to start it but not wait for it to finish. and you can do that by just placing the function in a spawn()
For example:
local function gg(function(plr) spawn(function(plr) for i = 1, 50 do plr.leaderstats.Cash.Value += 5 wait(0.2) end ) end) while wait(1) gg(Player Variable) end
This is going to run the function every one second but function is 10 seconds long. So it can run it multiple times without waiting the 10 seconds.