This is solved
I am a VERY newbie scripter (I can't really write any code myself without a reference, but slightly better with editing pre-made scripts) and I am trying to make a keycard door with a sound that plays when it opens and closes. It probably has something to do with the fact it's not all made for how I changed it, but it plays multiple times when it opens/closes if I don't instantly take away the tool from touching it. It mostly ends up going 2 or 3 times. (Hope you understand) How do I fix this? This is what I have: (I HAVE NO IDEA HOW TO MAKE THE CODE IN THE SPECIAL BLOCK THING, IF IT GETS TAKEN DOWN DUE TO THAT PLEASE TELL ME HOW :p)
script.Parent.Touched:Connect(function(hit) if hit.Parent.Name == "Access Armory" then script.Parent.Parent.Door1.Part1.Transparency = 1 script.Parent.Parent.Door1.Part1.CanCollide = false script.Parent.Parent.Door1.Part2.Transparency = 1 script.Parent.Parent.Door1.Part2.CanCollide = false script.Parent.Parent.Door2.Part1.Transparency = 0 script.Parent.Parent.Door2.Part1.CanCollide = true script.Parent.Parent.Door2.Part2.Transparency = 0 script.Parent.Parent.Door2.Part2.CanCollide = true script.Parent.Parent.Door2.Part3.Transparency = 0 script.Parent.Parent.Door2.Part3.CanCollide = true script.Parent.Parent.Door2.Part4.Transparency = 0 script.Parent.Parent.Door2.Part4.CanCollide = true script.Parent.Open:play() wait(3) script.Parent.Parent.Door1.Part1.Transparency = 0 script.Parent.Parent.Door1.Part1.CanCollide = true script.Parent.Parent.Door1.Part2.Transparency = 0 script.Parent.Parent.Door1.Part2.CanCollide = true script.Parent.Parent.Door2.Part1.Transparency = 1 script.Parent.Parent.Door2.Part1.CanCollide = false script.Parent.Parent.Door2.Part2.Transparency = 1 script.Parent.Parent.Door2.Part2.CanCollide = false script.Parent.Parent.Door2.Part3.Transparency = 1 script.Parent.Parent.Door2.Part3.CanCollide = false script.Parent.Parent.Door2.Part4.Transparency = 1 script.Parent.Parent.Door2.Part4.CanCollide = false script.Parent.Close:play() end
end)

10 comments
I have the audio and it plays, it just plays multiple times and I want it to play once
You need to add a debounce then. Ill edit my answer. edited
I tried adding it, and it completely disables the door. this happens with a lot of things I try to ad to that script. So, since you probably don't want to tell me how to entirely make a keycard door, I don't think it will work, and I don't think that's allowed since you can't make requests. Thanks though, I will keep it in mind
I have nothing better to do; I just edited your script.
wow. thank you, i feel bad for doing nothing but having someone else do it.
You're welcome, please mark it as answered
Funny this is, I have no idea how. I literally just created my account to ask this. I looked around, couldn't find it
It should be under my answer, called 'Mark as Answered'. I've never answered a question yet, so I'm not sure either.
Doesn't show up, I might just delete it, since that works.
dont delete it, or put SOLVED in it.