okay, I need help. How do i get a part to play a sound when another part/keycard hits the part that is needed to play a sound. to play the sound ive tried so many things but i don't know how to script? :( (it maybe a little tricky to read but im not English or american im from denmark so not the best you know)
COMMUNITY QUESTION
How do i get a part to play a sound when another part/keycard hits it?
1 answer
Hi there! Here's a script to put in your part that is touched by a keycard:
cooldown = 0
script.Parent.Touched:Connect(function(hit)
if hit.Parent.Name == "Keycard" and cooldown == 0 then
cooldown = 1
game.workspace:FindFirstChild("Part").Sound:Play()
wait(game.workspace:FindFirstChild("Part").Sound.TimeLength)
cooldown = 0
end
end)
This is assuming that the part that plays the sound is in the workspace. Make sure that the script to put in your part that is touched by the keycard is a regular script, and not a local script, otherwise it will not work. Let me know if you have any other questions! :D
This discussion is preserved as it was. New answers, comments, and votes are closed.

4 comments
okay thank you do i need to set a sound player in the one thats gonna play the sound?
Yes, click on toolbox, go to audio, and search for a sound you'd like :) make sure it's parenting the part that plays the sound
Okay Thank you so much
No problem! Make sure to mark this as "answered", I'd really appreciate it!