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

Why does the cooldown on my local script not work?

local player =  game.Players.LocalPlayer
local mouse = player:GetMouse()



mouse.KeyDown:connect(function(key)
	if key == "e" then
		print("Pressed e")
		local newPart = Instance.new("Part",game.Workspace)
		newPart.BrickColor = BrickColor.new("Storm blue") 
		
		wait(4)
		
		
	end
	
end)



Wait is not working? I tried placing it between both ends, and at the very end of the script but it doesn't work

1 answer

I suggest using UserInputService instead of an event. Also you need to use debounce and cooldowns

local UIS = game:GetService("UserInputService")

local debounce = false local cooldown = true

UIS.InputBegan:Connect(function(input, isTyping) if isTyping then return

elseif input.KeyCode == Enum.KeyCode.E then if debounce == false then debounce = true

--Do stuff here

wait(4) end end end)

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