So I'm trying to make a script where if a button is clicked, a leaderstat value goes up by one after twenty seconds. However, I only want the GUI the button is attached to to pop up every twenty seconds. The leaderstat value part works fine, but the twenty seconds part doesn't. This is my code:
local debounce = true
script.Parent.MouseButton1Click:connect(function()
script.Parent.Parent.Visible = false
debounce = false
wait(20)
debounce = true
for _,Player in pairs(game.Players:GetPlayers()) do
if Player:FindFirstChild("leaderstats") then
Player.leaderstats.Videos.Value = Player.leaderstats.Videos.Value +1
end
end
end)

1 comment
You only set the gui’s visibility to false in your script, not true.