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

Is this script correct?

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

✓ Accepted answer
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)

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.

5 comments

0

I think it is audio1:Play(), not play audio1.

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.

0

Then I would use the comment "--" so it doesnt seem a part of the script.

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.

0

areiy your script idea is horrible.

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