Ok so I'm somewhat familiar with Lua, I'd say I'm somewhere between basic and intermediate. I'm making a machine that makes money then burns it (just for giggles). I'm just using it to test out certain codes and aspects I just recently learned. To make the money I'm using a while loop and Instancing. The code works fine. My problem started when I tried making an on/off button. I have a boolvalue located within the model named "Activated" and the while loop is dependent on that. i noticed the off button works (perhaps because it broke the loop) Is there a way to temporarily stop the loop without breaking it? In other words, how would I make my on button reactivate it.
This is the code that creates the money(yes i spelled conveyor wrong, don't roast ;-;)
active = game.Workspace.ConveryorBelt.Activated
testpart = game.Workspace.ConveryorBelt.Maker
while active.Value == true do
newpart = Instance.new("Part", game.Workspace.Money)
newpart.BrickColor = BrickColor.new("Lime green")
newpart.Size = Vector3.new(1, .5, 2)
newpart.Position = testpart.Position
newpart.TopSurface = ("Smooth")
newpart.Name = ("Money")
wait(1)
end
And these are the codes that control the buttons and set the bool value to true/false
Off
active = game.Workspace.ConveryorBelt.Activated
function off ()
active.Value = false
end
script.Parent.ClickDetector.MouseClick:Connect(off)
On
active = game.Workspace.ConveryorBelt.Activated
function on ()
active.Value = true
end
script.Parent.ClickDetector.MouseClick:Connect(on)

6 comments
u put a wait() in da loop
also u r doing destruction of government property. By law, if the damage exceeds $100, the defendant is subject to a fine of up to $250,000, ten years imprisonment, or both. So watch out
There is a wait in da loop and also...I am the government >:)
dam
if there is wait() in da loop u should make da wait() longer
like, not 0