I am trying to make a cookie clicker game on my surfacegui. When you have 100 cookies or more you can buy a Worker, who makes the cookies with a loop, but the loop i put Mouse Down function does not work. The loop stops when 2 cookies are added but it cant add more than 2 cookies.. Help?
local cookie = script.Parent local noob = script.Parent.Parent.NoobWorker.Script local cooki21e = script.Parent.Parent.Parent.Parent.RealAmount.IntValue local cooke1 = script.Parent.Parent.Parent.Parent.RealAmount local oneNOOB = script.Parent.Parent.Parent.Parent.Noob1 script.Parent.MouseButton1Down:Connect(function() if cooki21e.Value < 100 then print("Below 100") elseif cooki21e.Value > 100 then cooki21e.Value = cooki21e.Value - 100 cooke1.Text = cooki21e.Value oneNOOB.Visible = true print("Above 100, taking 100 cookies") while true do wait(1) cooke1.Text = cooki21e.Value + 1 end end end)
The problem is that you are not changing the IntValue value in the loop. Add this line of code before line 17 to fix the issue:
cooki21e.Value = cooki21e.Value + 1
Also, I noticed you mention: "When you have 100 cookies or more you can buy a Worker". If that is the intended functionality, then I suggest you change line 10 to this as well:
elseif cooki21e.Value >= 100 then
This will let players buy a worker at 100 rather than 101.