You’re really close. It’s a debounce, not a buffer though. The terminology comes from electronics, where certain types of input can be sporatic and mess up your input if you don’t add a cooldown like you want. This is the only change I see that you need to make.
E = true
for i, Button in pairs(frame:GetChildren()) do
if Button:IsA(“TextButton”) then
Button.MouseButton1Click:Connect(function()
if E == true then -- this line here
E = false
wait (5)
E = true
end
end)
end
end
I also cleaned up the code a little and fixed a couple of minor mistakes.
local frame = script.Parent
local toggle = false
for _, button in pairs(frame:GetChildren()) do
if button:IsA("TextButton") then
button.MouseButton1Click:Connect(function()
if toggle then
task.wait(5)
toggle = false
elseif not toggle then
toggle = true
task.wait(5)
toggle = false
end
end)
end
end
Thank you, but the script you wrote has the same flaw as his. When you click the button it will have a 5 second delay after first click but after that it will let you click unlimited. Please take resetting in account as well
That and i want it to activate the other script. Its a ‘press play’ play button.
Edit: bassicialy the entire game is about pressing a block and once you press the block the game ends and you get 1 point added to your name. When the game ends you have the option to “play again.” I was going to try to sell admin or something as well. I’m doing it more for the learning than the fun or money
local frame = script.Parent
frame.Visible = false
local toggle = false
for _, button in pairs(frame:GetChildren()) do
if button:IsA("TextButton") then
button.MouseButton1Click:Connect(function()
if toggle then
toggle = false
frame.Visible = false
elseif not toggle then
toggle = true
frame.Visible = true
end
end)
end
end
Your script doesn’t mention any other scripts but will make all the buttons inside the “Frame” instance when clicked toggle the visibility of the frame. Make sure the script is a local script placed inside the frame.
local frame = script.Parent
frame.Visible = false
for _, button in pairs(frame:GetChildren()) do
if button:IsA("TextButton") then
button.MouseButton1Click:Connect(function()
if button:GetAttribute("Deb") then return end
button:SetAttribute("Deb",true)
frame.Visible = not frame.Visible
wait(5)
button:SetAttribute("Deb",false)
end)
end
end