Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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)]
	
	if i%20 == 0 then
	
		local currentpos = Vector3.new( math.random(-1700, 1700), math.random(710, 2500), math.random(-1700, 1700) )
		local frompos = currentpos
		local targetpos = Vector3.new( math.random(-1700, 1700), math.random(710, 2500), math.random(-1700, 1700) )
		
		local rotation = 0
		
		local speed = math.random()*1.5+0.1
		local rotspeed = ( math.random() - 0.5 ) * 2 * 2.5
		local factor = 0
		
		p.CFrame = CFrame.new(currentpos)
		
		local dist = (frompos - targetpos).magnitude
		
		local loop = function()
			rotation = rotation + rotspeed
			if rotation > 180 then rotation = rotation - 360 end
			if rotation < -180 then rotation = rotation + 360 end
			
			factor = factor + speed / dist
			if factor > 1 then
				factor = 0
				targetpos = Vector3.new( math.random(-1700, 1700), math.random(710, 2500), math.random(-1700, 1700) )
				frompos = currentpos
				dist = (frompos - targetpos).magnitude
				rotspeed = ( math.random() - 0.5 ) * 2 * 3
			end
			
			currentpos = frompos:Lerp(targetpos, factor)
			p.CFrame = CFrame.new(currentpos) * CFrame.Angles( 0, math.rad(rotation), 0 )
		end
		game:service("RunService").Stepped:connect(loop)
		
	end
end
****~~~~~~~~~~~~~~~~~
`[](http://)`

1 comment

1

Fix the formatting please.

1 answer

This may not be right but when you put end at 29 i think it stops the script there

This discussion is preserved as it was. New answers, comments, and votes are closed.