I want to create a click limit for a part

i want to make a limit for my part so that i could only click every 30 seconds

I am very bad at scripting and therefore could not find out, but what I have tried is under every butten event just to write wait(30) but it dident realy work

and that’s why I googled a lot and looked in the dev forum but didn’t really find anything

here would be the script any help is very welcome

script.Parent.MouseClick:Connect(function(click)
	
	local event = math.random(1,3)
	print(event)
	
	if event == 1 then wait(30)
		local part = workspace.Button
		local BadgeService = game:GetService("BadgeService")
		part.ClickDetector.MouseClick:Connect(function(player)
			BadgeService:AwardBadge(player.UserId, 2124772323)
		end)
	elseif event == 2 then
		for i, v in pairs(workspace.ZombieSpawns:GetChildren()) do
			local Zombie = game.ServerStorage.Zombie:Clone()
			Zombie.delete.Disabled = false
		    Zombie.Parent = workspace
		    Zombie.Torso.CFrame = v.CFrame
		end
	elseif event == 3 then
		
	
	end
end)

please give me an example i don’t want to get a whole script from you.

What you could do is add a little cooldown or debounce by doing it like this

local onCooldown = false

button.MouseClick:Connect(function()
    if onCooldown == false then
      onCooldown = true

      -- your code

       task.delay(30, function()
           onCooldown = false
       end)
    end
end)

Sorry for the bad formatting I am on mobile but it should fix itself in the script editor, tried my best to format it right with spaces lol

local touched = false
local waitlimit = 30

script.Parent.MouseClick:Connect(function(click)

if touched then print("this part is already touched") return end

touched = true
print("not toucheable")

wait(tonumber(waitlimit))
touched = false
print("now toucheable")

end)

Thank you I even learned something becouse of you.

1 Like