How do I set a cooldown for spawning in blocks?
I want to be able to spawn a block when you click a gui and I got this.
01 | local button = script.Parent |
02 | local part 1 = script.Parent |
03 | local part 2 = workspace.partspawn |
04 | local clickdetector = button |
06 | local function spawnPart() |
07 | local newPart = Instance.new( "Part" ) |
08 | newPart.Parent = workspace |
09 | newPart.Position = part 2. Position |
10 | newPart.BrickColor = BrickColor.Blue() |
11 | newPart.Size = Vector 3. new( 15 , 15 , 15 ) |
15 | clickdetector.MouseButton 1 Click:Connect(spawnPart) |
This works, but if you use an autoclicker, it spawns a lot of blocks really quick and lags the game. How could you make it so you can only click it once every 0.1 seconds?
Thank you very much.