i am trying to make this part spawn a part when pressed ( with cooldown ), please explain why it doesnt work:
UserInputService = game:GetService("UserInputService")
local rannum = 1
local debounce = true
local cooldown = 0.5
UserInputService.InputBegan:Connect(function(key, typing)
if typing then return end local button = Enum.KeyCode.Delete if key.KeyCode == button then if debounce then debounce = false if rannum == 1 then local poopspawned = 0 while true do if poopspawned >= 1 then wait() poopspawned = poopspawned + 1 local poop = Instance.new("Part", game.Workspace) time() poop.Color = Color3.new(0,0,0) poop.Position = Vector3.new(0,15,0) end wait(2) debounce = true end end end end
end)