I am making factory conveyor for a challenge that spawns boxes and sends them down the conveyor belt after you click the on button. How should I spawn boxes?
The on button script:
function onClicked(PlayerWhoClicked)
local c = script.Parent.Parent.Conveyer
local velocity = 1000
if script.Parent.Size == Vector3.new(1,.6,1) then
if c then
c.Velocity = Vector3.new(velocity,0,0)
script.Parent.Size = Vector3.new(1,.4,1)
script.Parent.Position=script.Parent.Position-Vector3.new(0,.2,0)
script.Parent.Parent.Off.Size = Vector3.new(1,.6,1)
wait()
end
end
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
The off button script is pretty much the same.
if I want to spawn bricks should I do something like this: (after line 9)
for I=1, 10000000000000000000000000000000000 do
if script.Parent.Size == Vector3.new(1,.4,1) then
b = script.Parent.Parent.Box:clone()
b.Position=b.Position-Vector3.new(0,2,0)
end
end
****Now I have a new idea please somebody reply if it works. Should I try using a repeat until thingy so it repeats the part being cloned every 2 seconds until the off button is pressed and the on button is up?

3 comments
There's one small thing in your 2nd script that needs changing. When your doing the for loop, i always needs to be lower case. Also, looping the script that many times (which is close to infinity) would crash the server. Add a wait time to it (no less that .01 sec.). BTW what object does "script.Parent" represent in your script?
Script.Parent is the on button and script.Parent.Parent is a model that the conveyor and buttons and etc. are in. also the capitol i is something stupid I accidentally did in studio but I did the wait I just forgot that while re-typing it. I think it still doesn't work
It doesn't matter if the 'i' is captial or not, or if it's even an 'i'! It could be whatever you want as it is simply a variable that stores a value.