How would I fix this so it doesn't spam the audio and brightness, but keeps the wait timers in the code without removing debounce?
local shortcut = game.Workspace.Map
local lighting = shortcut.Lighting
local flicker = lighting.Ceiling_light.Lightbulb.SpotLight
local audio = lighting.Ceiling_light.Lightbulb["Lightbulb Flicker"]
local audioo = lighting.Ceiling_light.Lightbulb.zap
local debounce = false
script.Parent.Touched:Connect(function()
if debounce == false then
debounce = true
if script.Parent.Touched then
audio:play()
flicker.Brightness = 0
wait(1)
flicker.Brightness = 15
audioo:play()
wait(1)
flicker.Brightness = 0
wait(1)
flicker.Brightness = 15
end
debounce = false
end
if script.Parent.TouchEnded then
end
script.Parent:Destroy()
end)

2 comments
It fixed my problem, thank you.
No problem, glad I've helped.