Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Anybody know why the debounce in this script isnt working?

Asked by 3 years ago
local debounce = true
local cooldown = 3
local Sound = script.Parent.Parent.Parent.taw.Sound
local Light = script.Parent.Parent.Parent.taw.Light
local Particle1 = script.Parent.Parent.Parent.taw.Particle1
local Particle2 = script.Parent.Parent.Parent.taw.Particle2
local ParticleEmitter1 = script.Parent.Parent.Parent.taw.ParticleEmitter1
local ParticleEmitter2 = script.Parent.Parent.Parent.taw.ParticleEmitter2
local ParticleEmitter3 = script.Parent.Parent.Parent.taw.ParticleEmitter3
local ParticleEmitter4 = script.Parent.Parent.Parent.taw.ParticleEmitter4
local ParticleEmitter5 = script.Parent.Parent.Parent.taw.ParticleEmitter5
local ParticleEmitter6 = script.Parent.Parent.Parent.taw.ParticleEmitter6
local ParticleEmitter7 = script.Parent.Parent.Parent.taw.ParticleEmitter7
local ParticleEmitter8 = script.Parent.Parent.Parent.taw.ParticleEmitter8
local ParticleEmitter9 = script.Parent.Parent.Parent.taw.ParticleEmitter9
local ParticleEmitter10 = script.Parent.Parent.Parent.taw.ParticleEmitter10

script.Parent.MouseClick:Connect(function()
    if debounce then
        debounce = false
    end
    Sound:Play()
    Light.Enabled = true
    Particle1.Enabled = true
    Particle2.Enabled = true
    ParticleEmitter1.Enabled = true
    ParticleEmitter2.Enabled = true
    ParticleEmitter3.Enabled = true
    ParticleEmitter4.Enabled = true
    ParticleEmitter5.Enabled = true
    ParticleEmitter6.Enabled = true
    ParticleEmitter7.Enabled = true
    ParticleEmitter8.Enabled = true
    ParticleEmitter9.Enabled = true
    ParticleEmitter10.Enabled = true
    wait(0.1)
    Light.Enabled = false
    Particle1.Enabled = false
    Particle2.Enabled = false
    ParticleEmitter1.Enabled = false
    ParticleEmitter2.Enabled = false
    ParticleEmitter3.Enabled = false
    ParticleEmitter4.Enabled = false
    ParticleEmitter5.Enabled = false
    ParticleEmitter6.Enabled = false
    ParticleEmitter7.Enabled = false
    ParticleEmitter8.Enabled = false
    ParticleEmitter9.Enabled = false
    ParticleEmitter10.Enabled = false
    wait(cooldown)
    debounce = true
end)

2 answers

Log in to vote
0
Answered by
MattVSNNL 620 Moderation Voter
3 years ago

Your code is very messy so I'll fix your code and try and fix your debounce

local debounce = false
local cooldown = 3
local Sound = script.Parent.Parent.Parent.taw.Sound
local Light = script.Parent.Parent.Parent.taw.Light

for i, particles in pairs(script.Parent.Parent.Parent.taw:GetDescendants()) do
    if particles:IsA("ParticleEmitter") then
        ParticleEmmiters = particles
    end
end

script.Parent.MouseClick:Connect(function()
    if debounce == false then
        debounce = true
    end
end
    Sound:Play()
    Light.Enabled = true
    ParticleEmmiters = true
    wait(0.1)
    Light.Enabled = false
    ParticleEmmiters = false
    wait(cooldown)
    debounce = false
end)

I don't know if this works but tell me if something doesn't work!

0
It didnt work, by the way im a begginer scripter so i have a very hard time figuring out the problem User#42963 0 — 3y
0
What are you even trying to make MattVSNNL 620 — 3y
0
I realized the problem, I had to add another end to the bottom. Was trying to make an explosion, thanks for the help User#42963 0 — 3y
0
is GetDescendants different with GetChildren ? iMazariuz 36 — 3y
View all comments (2 more)
0
GetDescendants gets every children plus the things inside of it, Get children only gets the children and not whats inside MattVSNNL 620 — 3y
0
If it works please accept my anwser MattVSNNL 620 — 3y
Ad
Log in to vote
0
Answered by 3 years ago

for debouce use

local debounce = false -- put this on the top

if not debounce then -- add this in function

debounce = true

debounce = false -- add this after wait

Answer this question