Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to play sound when button clicked?

So im making a gui and i want the buttons to play a sound when somebody click on it i tried doing

Helpbutton.MouseButton1Click:Connect(function()
	Help.Sound:Play
	wait(.1)
	Help.Sound:Stop
end)

but then this error comes

Players.Noman538.PlayerGui.Help.LocalScript:3: Expected '(', '{' or <string>, got 'wait'

2 answers

✓ Accepted answer

Play and Stop are both methods of Sound. In other words, they're functions. Basic syntax requires parentheses to wrap the function call as a form of providing arguments to the given parameters. Even without parameters that are built into functions, this practice is still mandatory across all languages. To fix this issue, place a pair of parentheses at the respective places.

Sound:Play()
Sound:Stop()

This discussion is preserved as it was. New answers, comments, and votes are closed.