Hi, I'm trying to make a script that will creates multiple bricks at random positions that move upwards after being created. I've managed to succeed with the first part, but I have no idea how to make the bricks move up after being created.
I've tried using coroutines to make two loops work together, but it didn't work well at all and the bricks moved upwards slower over time and became less smooth. Here's a video showing the problem.
I'm really stumped by this so any help would be appreciated, thanks!
Here's the code:
local debris = game:GetService("Debris")
local cam = workspace.CurrentCamera
local rand = math.random
local num = 50
while true do
for i = 0, 10 do
local brick = Instance.new("Part")
brick.Anchored = true
brick.CanCollide = false
brick.Size = Vector3.new(1, 1, 1)
brick.Parent = workspace
brick.CFrame = CFrame.new(cam.CFrame.Position + (cam.CFrame:VectorToWorldSpace(Vector3.new(0, 0, 0)) + Vector3.new(rand(-num, num), rand(-num, num), rand(-num, num))))
debris:AddItem(brick, 0.75)
coroutine.resume(coroutine.create(function() --part that moves bricks up
while true do
brick.CFrame = brick.CFrame * CFrame.new(0, 0.1, 0)
wait()
end
end))
end
wait()
end
EDIT: After numerous replies which haven't addressed the problem, I think I phrased my problem extremely poorly, which I apologize for. Even while trying to thread the two loops, the bricks very quickly lose speed and move extremely roughly.

3 comments
also change brick.Anchored to false or they wont move up
Hi, thanks for the reply. Is there no way to make them move with CFrame?
no cframe only changes the position, it doesnt move in the way u want(the way i think u want)