Hey guys, sorry for asking again, but my If statement in the end is not working, what's the problem? When the var Buttonsleft == 0, it just doesn't print "All buttons done", why?
PS: Ignore the strange words like "porta", those are in portuguese... PS: I think the repeated functions can be transformed in just one, maybe that's a bad practice, but i just don't know how to do it, sorry :/
clickquantity1 = 5
clickquantity2 = 5
clickquantity3 = 5
clickquantity4 = 5
Buttonsleft = 4
porta1 = game.Workspace.Porta
porta2 = game.Workspace.Porta2
porta3 = game.Workspace.Porta3
porta4 = game.Workspace.Porta4
Table = {porta1, porta2, porta3, porta4}
function clickbutton1()
workspace.Painel1.SurfaceGui.TextLabel.Text = clickquantity1 .. " Click's left"
clickquantity1 = clickquantity1 - 1
if clickquantity1 == 0 then
workspace.Painel1.SurfaceGui.TextLabel.Text = "Finished Button"
Buttonsleft = Buttonsleft - 1
elseif clickquantity1 < 0 then
workspace.Painel1.SurfaceGui.TextLabel.Text = "Buttons left: " .. Buttonsleft
end
end
game.Workspace.Button1.ClickDetector.MouseClick:Connect(clickbutton1)
function clickbutton2()
workspace.Painel2.SurfaceGui.TextLabel.Text = clickquantity2 .. " Click's left"
clickquantity2 = clickquantity2 - 1
if clickquantity2 == 0 then
workspace.Painel2.SurfaceGui.TextLabel.Text = "Finished Button"
Buttonsleft = Buttonsleft - 1
elseif clickquantity2 < 0 then
workspace.Painel2.SurfaceGui.TextLabel.Text = "Buttons left: " .. Buttonsleft
end
end
game.Workspace.Button2.ClickDetector.MouseClick:Connect(clickbutton2)
function clickbutton3()
workspace.Painel3.SurfaceGui.TextLabel.Text = clickquantity3 .. " Click's left"
clickquantity3 = clickquantity3 - 1
if clickquantity3 == 0 then
workspace.Painel3.SurfaceGui.TextLabel.Text = "Finished Button"
Buttonsleft = Buttonsleft - 1
elseif clickquantity3 < 0 then
workspace.Painel3.SurfaceGui.TextLabel.Text = "Buttons left: " .. Buttonsleft
end
end
game.Workspace.Button3.ClickDetector.MouseClick:Connect(clickbutton3)
function clickbutton4()
workspace.Painel4.SurfaceGui.TextLabel.Text = clickquantity4 .. " Click's left"
clickquantity4 = clickquantity4 - 1
if clickquantity4 == 0 then
workspace.Painel4.SurfaceGui.TextLabel.Text = "Finished Button"
Buttonsleft = Buttonsleft - 1
elseif clickquantity4 < 0 then
workspace.Painel4.SurfaceGui.TextLabel.Text = "Buttons left: " .. Buttonsleft
end
end
game.Workspace.Button4.ClickDetector.MouseClick:Connect(clickbutton4)
if Buttonsleft == 0 then
print("All buttons done")
end

2 comments
the if statement is only running once, since the value of buttonsleft isnt going to initially be 0 and its never asked to run again after the value is 0, it will never print.
Hm.. I think i see it, It's like the if is seeing that Buttonsleft is not zero, and then If just do nothing, is that right?