Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Is there a way to stop Screen GUI button spamming?

Is there a way to slow down the player from pushing the button real fast like a delay?

local Main = script.Parent:FindFirstChild('Main')
local Test = Main.Glass:FindFirstChild('Test') -- This is a screen gui Button

Test.MouseButton1Down:connect(function()
	local rS = game:GetService("ReplicatedStorage")
	local remote = rS.EventsBlocks:WaitForChild("Test1")
	remote:FireServer()
end)

1 answer

✓ Accepted answer

you need a debounce and to get that you type the following

debounce = false
if not debounce then
debounce = true
wait(the time u want to wait in here)
debounce = true

here is the full script if u dont understand

local Main = script.Parent:FindFirstChild("Main")
local Test = Main.Glass:FindFirstChild("Test")
    debounce = false
    Test.MouseButton1Down:Connect(function()
    if not debounce then--this will see if debounce is false and if it is then it will run
    debounce = true--this sets the debounce to true so the function cant be run again
    	local rS = game:GetService("ReplicatedStorage")
    	local remote = rS.EventsBlocks:WaitForChild("Test1")
    	remote:FireServer()
    	wait(time in here)
    	debounce = false--after the time set debounce will return to false so the function can run
    end)

also when you attempt to find the first child you dont use ' instead you use "

2 comments

0

I understand now thank you very much. Also thank for the tip about ' and "

0

happy to help, im also learning lua from this site and yt vids so im happy to help

This discussion is preserved as it was. New answers, comments, and votes are closed.