I have a button that is supposed to open after like 15 clicks. I put a value in the button thats set at 0 and I want the script to add 1 to the button each time it's clicked until it reaches 15 then does an action. I'm pretty new and terrible at scripting so this is what I have so far. How do i get it to actually do math if not open + 1?
open = script.Parent.Value
function onClicked()
if open >= 15 then
open += 1
else
for _,v in pairs (script.parent.parent.parent["Hall Light"]:GetChildren()) do
if v:IsA("Part") then
v.Anchored = false
end
end
end
end
So i figured it out, this is my final code that got it to work
open = script.Parent.Open.Value
function onClicked()
if open < 15 then
open = open + 1
elseif open >= 15 then
for _,v in pairs (script.parent.parent.Parent.HLG:GetChildren()) do
if v:IsA("Part") then
v.Anchored = false
end
end
end
end
script.Parent.ClickDetector.MouseClick:Connect(onClicked) --dont touch

3 comments
So it doesn't seem to be working. It isn't adding to the Value that I have inside the button.
are you using an int value?
Yes