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

How do I set a cooldown for spawning blocks?

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

	local button = script.Parent
	local part1 = script.Parent
	local part2 = workspace.partspawn
	local clickdetector = button
	 
	local function spawnPart()
	    local newPart = Instance.new("Part")
	    newPart.Parent = workspace
	    newPart.Position = part2.Position
	    newPart.BrickColor = BrickColor.Blue()
	    newPart.Size = Vector3.new(15,15,15)
	    wait(1)
	end
	 
	clickdetector.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

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!!

4 comments

0

Where would I put this? I put it ion and doesn't work. Any other solutuions?

0

Probably after function part()

0

that didnt work either..

0

that didnt work...

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