Can someone help with this script?
it won't work correctly i don't know what the bug is
~~~~~~~~~~~~~~~~~
local colors = {
BrickColor.new("White"),
BrickColor.new("Bright red"),
BrickColor.new("Black"),
BrickColor.new("Bright blue"),
}
for i = 1, 1200 do
local p = Instance.new("Part",workspace)
p.Anchored = true
p.Size = Vector3.new( math.random(10, 160), math.random(4,60), math.random(10, 160) )
p.CFrame = CFrame.new( math.random(-1700, 1700), math.random(710, 2500), math.random(-1700, 1700) )
p.CanCollide = false
p.TopSurface = 0
p.BottomSurface = 0
p.BrickColor = colors[math.random(1,#colors)]
03 | local currentpos = Vector 3. new( math.random(- 1700 , 1700 ), math.random( 710 , 2500 ), math.random(- 1700 , 1700 ) ) |
04 | local frompos = currentpos |
05 | local targetpos = Vector 3. new( math.random(- 1700 , 1700 ), math.random( 710 , 2500 ), math.random(- 1700 , 1700 ) ) |
09 | local speed = math.random()* 1.5 + 0.1 |
10 | local rotspeed = ( math.random() - 0.5 ) * 2 * 2.5 |
13 | p.CFrame = CFrame.new(currentpos) |
15 | local dist = (frompos - targetpos).magnitude |
17 | local loop = function () |
18 | rotation = rotation + rotspeed |
19 | if rotation > 180 then rotation = rotation - 360 end |
20 | if rotation < - 180 then rotation = rotation + 360 end |
22 | factor = factor + speed / dist |
25 | targetpos = Vector 3. new( math.random(- 1700 , 1700 ), math.random( 710 , 2500 ), math.random(- 1700 , 1700 ) ) |
27 | dist = (frompos - targetpos).magnitude |
28 | rotspeed = ( math.random() - 0.5 ) * 2 * 3 |
31 | currentpos = frompos:Lerp(targetpos, factor) |
32 | p.CFrame = CFrame.new(currentpos) * CFrame.Angles( 0 , math.rad(rotation), 0 ) |
34 | game:service( "RunService" ).Stepped:connect(loop) |
end
****~~~~~~~~~~~~~~~~~
[](http://)