function onClick(click) for i,v in pairs (script.Parent:GetChildren()) do if v.ClassName == "ScreenGui" then c = v:Clone() c.Parent = click.PlayerGui end end end script.Parent.ClickDetector.MouseClick:connect(onClick)
How would I add a cooldown to this? https://gyazo.com/1a50b42fd23c99c0c32e1090132af3c1 - Inside of it Script i'm showing up here - https://gyazo.com/d116ff7d6e0d6a75acec3f05be34c5ac The script that might be causing the issues - https://gyazo.com/5ce102653073a10c0cf71d0e9b6c795f
For this, you're going to want to use a debounce as theking48989987 commented on your post. To do this you just need a simple true or false statement
local debounce = false -- Saying it's not being used function onClick(click) if debounce == false then debounce = true -- Checking if it's not being used, and if it's not, setting it to being used! for i,v in pairs (script.Parent:GetChildren()) do if v.ClassName == "ScreenGui" then c = v:Clone() c.Parent = click.PlayerGui end end wait(3) -- waiting 3 seconds debounce = false -- Setting it back to not being used, therefor it can be used again end end script.Parent.ClickDetector.MouseClick:connect(onClick)