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

I made a script that should play a sound, but it doesn't work. Where have I done wrong?

So I tried making a small, hidden button in a place I'm currently working on that plays a certain sound for everyone in the server. The script itself is:

owo = script.Parent
sound = owo:WaitForChild('Sound')

function onButtonClick()
 sound:Play()
end
 
owo.MouseButton1Click:connect(onButtonClick)

The thing is, it doesn't work, like, at all. It doesn't play server-wide or only on the local client. Nothing really happens. Can anyone explain where I've done wrong? I did include a ClickDetector and the sound itself is a child of the button itself. Thanks in advance!

3 comments

0

forgot to mention, the script is also a child of the button

0

It should be in a local script if it isn't. If you want it to happen for all players, you should look into remote events.

0

the place is not FE, but sure, I guess? thanks anyways.

2 answers

' :connect() ' is deprecated. You must use ' :Connect() ' instead. If this doesn't help, I am not sure unless it's just a simple issue locating the audio or button.

3 comments

0

thanks. also i just realized, i forgot to put "local" before setting variables :P

0

doesn't work, thanks anyways. i think it's supposed to work only on the local client instead of the server. guess i'll have to look forward to remoteevents, but anyways, i'm probably going to give up on the development.

0

did putting 'local' fix it?

Do you have a click detector in the part? If so it’s not mousebutton1click it’s just mouseclick. If not, idk if that will ever sense a click.

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