Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 7 years ago
Edited 7 years ago

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!

0
forgot to mention, the script is also a child of the button SirLuisFonsi 9 — 7y
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. mattscy 3725 — 7y
0
the place is not FE, but sure, I guess? thanks anyways. SirLuisFonsi 9 — 7y

2 answers

Log in to vote
2
Answered by 7 years ago

' :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.

0
thanks. also i just realized, i forgot to put "local" before setting variables :P SirLuisFonsi 9 — 7y
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. SirLuisFonsi 9 — 7y
0
did putting 'local' fix it? SchonATL 15 — 7y
Ad
Log in to vote
0
Answered by 7 years ago

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.

Answer this question