How to make if player click button then sound play ? button = script.Parent Sound = script.Parent.Sound
✓ ANSWER ACCEPTED
How to make if player click button then sound play ?
1 answer
✓ Accepted answer
Your half way there, just need to add the click function and sound ID and attributes.
local Button = script.Parent
local Sound = script.Parent["Sound"]
Sound.Looped = true
Sound.SoundId = "rbxassetid://AUDIO_ID" -- change AUDIO_ID to an audio asset ID.
Sound.Volume = 1
local function PlaySound()
if Sound.Playing == true then -- if its playing then the sound will be turned off.
Sound.Playing = false
else
if Sound.Playing == false then -- if its not playing the sound will be turned on.
Sound.Playing = true
end
end
Button.MouseButton1Down:Connect(PlaySound)
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
This isn't a request site. There are plenty of tutorials on YouTube to learn how to code in Roblox, watch them and learn to code instead of relying on other people to do it for you. If you need help with your attempted code, then you should provide it so we can help you solve whatever the issue may be.