I've been looking around the wiki for scripts on onClicked scripts and tried configuring
function onClicked(playerWhoClicked)
script.Parent.BrickColor = BrickColor.Random()
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
to work with playing sounds (of course deleting the brick color changing bit) but to no avail. I'm trying to use "Play ( )" but all the time it says "Unknown global 'Play'"
For example, this script
function onClicked(playerWhoClicked)
Play ( )
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
shows the Unknown global "Play" message.
I also tried
function onClicked(playerWhoClicked)
do Play ( )
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
Which didn't give me the error, but when I tried it in game it didn't work.
Finally! After messing around with the things, I figured out what I needed to do. With the help from both of the answers, I came up with this! Sadly I can't give rep to both, but I mainly got the help from the first.
local sound = game.workspace.Sound
function onClicked(playerWhoClicked)
sound:Play ( )
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
For anyone looking at this as help, you can rename "Sound" in the first line to anything your sound is renamed to.

2 comments
Mind posting the script that gave you this error? Once we have that, we should be able to help!
^ I posted another piece of script that gave me the error.