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

Would anybody like to help me fix this Generation script?

z = math.random(-24,24)
t = math.random(.009,.05)
NewPart = Instance.new("Part")

for i = 1, 900 do
	NewPart.Parent = Workspace
	NewPart.Size = Vector3.new(3.6, 1.2, 2)
	NewPart.Position = Vector3.new(22, 18.19, z)
	NewPart.BrickColor = BrickColor.new("Really black")
	
	for i = 1,146 do
		NewPart.CFrame = NewPart.CFrame* CFrame.new(0,.2,0)
			wait(t)
	end
	NewPart.remove()
		wait(5)
end

Every 5 seconds, it is supposed to create one block with a random Z vector as shown at the very top. It only creates one block, and then the script stops. I think it's the NewPart.remove() , but I'm not sure. What could I try instead of that?

1 answer

✓ Accepted answer

If you want to use the remove() function, it would be NewPart**:**remove()

local t = math.random(.009,.05)

for i = 1, 900 do
	local z = math.random(-24,24)
	NewPart = Instance.new("Part")
	NewPart.Parent = Workspace
	NewPart.Size = Vector3.new(3.6, 1.2, 2)
	NewPart.Position = Vector3.new(22, 18.19, z)
	NewPart.BrickColor = BrickColor.new("Really black")

	for i2 = 1,146 do
		NewPart.CFrame = NewPart.CFrame* CFrame.new(0,.2,0)
		wait(t)
	end
	
	NewPart.remove()
	wait(5)
end

5 comments

0

Thank you! I must've accidentally done that, and then missed it while proof reading.

0

Happy to help!

0

Oh, there's also another problem. It doesn't recalculate the random Z value. Could you help me with that as well?

0

I have changed my post. It should now generate a new part with a new z value every time the first for loop scope runs.

0

Thanks, it does.

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