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

Is this script correct?

Asked by 10 years ago

if game.Workspace.Part.ClickDetector then play audio == ('142435409') end

I am trying to get a part when I click it, it will play a certain audio. Is this script correct for that?

2 answers

Log in to vote
0
Answered by 10 years ago
sound = game.Workspace.Sound --Change this to whatever it is in your game

function onClicked()
    sound:Play()--For it to play (142435409) you just should make an audio in workspace, and put that in the SoundId
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)

Ad
Log in to vote
-1
Answered by 10 years ago

If you are wanting it to play client-side make sure it is a Localscript first. If you are using click detectors then it should look something like this.

audio1 = game.Soundscape.Bomb --you can change this to whatever audio you want to play

function onClicked()
    play audio1
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)

****I am not sure if that itself will work, but it is basically what is needed for the click detector. I predetermined the audio track to play(in this case "Bomb" from the Soundscape, to simplify the script later on.

0
I think it is audio1:Play(), not play audio1. Perci1 4988 — 10y
0
The point of it was to give him a basic idea of how to work the Click Detector, because that seemed to be the part that he was having the largest issue with. areiydenfan00 115 — 10y
0
Then I would use the comment "--" so it doesnt seem a part of the script. AmericanStripes 610 — 10y
0
Did you not read the "****I am not sure if that itself will work, but it is basically what is needed for the click detector. -In other words, It is just for a structural thing so he knows where to put the function to play the audio and how the click detector should be set up. areiydenfan00 115 — 10y
0
areiy your script idea is horrible. iiShadster 0 — 10y

Answer this question