So I have a lever and when you pull it, it makes a sound. But I want it to play a special sound only when it gets clicked within 1 second. How would I do this? Here is what I have so far:
function matlever() -- manages the whole demat / move / mat thing if script.Parent.Variables.Power.Value == true and script.Parent.Variables.Override.Value == false then if status.Value == 0 then status.Value = 1 if converted == true then script.Parent.Variables.rdoor.Value = true end matleversound:Play() local g = script.Parent.Controls.Matlever.Land:GetChildren() for i = 1,#g do g[i].Transparency = 0 g[i].CanCollide = true end local g = script.Parent.Controls.Matlever.Fly:GetChildren() for i = 1,#g do g[i].Transparency = 1 g[i].CanCollide = false end fly.Value = true demat() move() elseif status.Value == 2 then status.Value = 3 matleversound:Play() local g = script.Parent.Controls.Matlever.Land:GetChildren() for i = 1,#g do g[i].Transparency = 1 g[i].CanCollide = false end local g = script.Parent.Controls.Matlever.Fly:GetChildren() for i = 1,#g do g[i].Transparency = 0 g[i].CanCollide = true end move() repeat wait(0.1) until script.Parent.Variables.ExtChange.Value == false mat() fly.Value = false status.Value = 0 if converted == true then script.Parent.Variables.rdoor.Value = false end end end end script.Parent.Controls.Matlever.Fly.Fly.ClickDetector.MouseClick:connect(matlever) script.Parent.Controls.Matlever.Land.Land.ClickDetector.MouseClick:connect(matlever)
You need to make the script wait until a second has passed...there's a name for this but I can't remember it. Anyways, I added the variable 'Able'. It makes the function only pass if 'Able' is set to true...This should work anyways, leave a comment if not. Hope I helped :P
Able=true function matlever() -- manages the whole demat / move / mat thing if Able==true then Able=false if script.Parent.Variables.Power.Value == true and script.Parent.Variables.Override.Value == false then if status.Value == 0 then status.Value = 1 if converted == true then script.Parent.Variables.rdoor.Value = true end matleversound:Play() local g = script.Parent.Controls.Matlever.Land:GetChildren() for i = 1,#g do g[i].Transparency = 0 g[i].CanCollide = true end local g = script.Parent.Controls.Matlever.Fly:GetChildren() for i = 1,#g do g[i].Transparency = 1 g[i].CanCollide = false end fly.Value = true demat() move() elseif status.Value == 2 then status.Value = 3 matleversound:Play() local g = script.Parent.Controls.Matlever.Land:GetChildren() for i = 1,#g do g[i].Transparency = 1 g[i].CanCollide = false end local g = script.Parent.Controls.Matlever.Fly:GetChildren() for i = 1,#g do g[i].Transparency = 0 g[i].CanCollide = true end move() repeat wait(0.1) until script.Parent.Variables.ExtChange.Value == false mat() fly.Value = false status.Value = 0 if converted == true then script.Parent.Variables.rdoor.Value = false end end end if Able=false then wait(1) Able=true end end end script.Parent.Controls.Matlever.Fly.Fly.ClickDetector.MouseClick:connect(matlever) script.Parent.Controls.Matlever.Land.Land.ClickDetector.MouseClick:connect(matlever)