Sound randomizer

  1. What do you want to achieve? I want to make a script that will randomizer sound

  2. What solutions have you tried so far? I have tried looking at youtube videos, free models, and even on the DevForums, but I found nothing as to what I was looking for.

Here’s how I want the script to work.

this is for my car crash game, I already have my trigger event.

function onTouch(part)
wait(0)
if part.Name == “Joint Break” then
print(“it hit it”)

now when you crash into let’s just say a wall that has a joint break in it.

then when it hits the wall, the script will then detect’s it and this is where the randomizer come into play.

  1. right after the print(“it hit it”) it will scan the IDs I put for the script, and I can put as many IDs as I want in it, it will even have names in them like (crash_1, 4816395722, crash_2, 5826497601, crash_3, 77739264) something like that.

  2. Once it picks an ID with the sound then it will instance a new sound into whatever part the script is inside of with the crash ID sound and name.

  3. and lastly once it instance it, it will then play the sound only 1 time and then remove the sound afterwards.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

```(function onTouch(part)
	wait(0)
	if part.Name == "Joint Break" then
	print("it hit it")
        --start the randomizer sound here and then remove this text your reading here afterward


	script.Parent.Hit_Sound_1.Playing = true
	wait(0.01)
	script.Parent.BreakSound.Disabled = true
	script.Parent.Material = Enum.Material.SmoothPlastic	
end
end
script.Parent.Touched:connect(onTouch))```

and that it.

Please do not ask people to write entire scripts or design entire systems for you.

First put the ids into a table

audioTable = {4345453, 4334534, 345435}

Then select the id from the table with

local randomId = audioTable[math.random(#audioTable)]

this is assuming you know how to play the audio after the id is picked from random

it took a bit to find out why it wasn’t working but it works thank you I can hear the sounds fine, the only thing you forgot to add to the code (local audioTable = {“rbxassetid://ID here”}) thank you

mark it a solution so we dont have to spam the comments like +50 replies without knowing the solution is already in