From my understanding, you want the Click variable to keep adding 1 until it hits 10 once a ClickDetector is clicked.
So in order to do this, you can do:
local Clicked = 0
script.Parent.ClickDetector.MouseClick:connect(function()
if Clicked < 10 then
for i = 0,10,1 do
Clicked = i
if Clicked == 10 then
end
wait(1)
end
end
end)
The for loop will start at 0(First number), it wants to end up at 10(middle number) and we are adding by 1(last number, a.k.a the increment), this is all happening per second(you can change how fast you want it to add by in the wait(n))
If I was wrong and you instead wanted to add 1 when its clicked then what you can do is:
local Clicked = 0
script.Parent.ClickDetector.MouseClick:connect(function()
if Clicked < 10 then
Clicked = Clicked + 1
else
print("Not less than 10, won't add.")
end
end)
Hope this helps :)
1 comment
You mean that it will loop adding value when you click on the part once? Or it adds one click when you press it once?