Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I set a cooldown for spawning blocks?

Asked by 2 years ago

I want to be able to spawn a block when you click a gui and I got this.

01local button = script.Parent
02local part1 = script.Parent
03local part2 = workspace.partspawn
04local clickdetector = button
05 
06local function spawnPart()
07    local newPart = Instance.new("Part")
08    newPart.Parent = workspace
09    newPart.Position = part2.Position
10    newPart.BrickColor = BrickColor.Blue()
11    newPart.Size = Vector3.new(15,15,15)
12    wait(1)
13end
14 
15clickdetector.MouseButton1Click: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.

2 answers

Log in to vote
0
Answered by 2 years ago

Try using task.wait(2) this should work just implement it somewhere in your script. Also you can change 2 to how long you want to wait() Hope this helps!!

0
Where would I put this? I put it ion and doesn't work. Any other solutuions? dannybuns03 11 — 2y
0
Probably after function part() theking66hayday 841 — 2y
0
that didnt work either.. dannybuns03 11 — 2y
0
that didnt work... dannybuns03 11 — 2y
Ad
Log in to vote
0
Answered by 2 years ago

anyone else know how to do this?

Answer this question