Is it possible to ban certain audios from being played inside of a game?

So, I was wondering if it would be possible to ban certain audios from being played inside a ROBLOX game, as people have been playing crash audios inside of my game which crashes the whole server.

I am not too sure how I could manage to script this, but I have searched through some of the devforum for an answer, yet I haven’t found anything.

If I found out a way, I could put them to a block list inside of my game.

For the game audios, I am using this Golden Boombox.

1 Like

Yes it is, just set something like this

local bannedaudio = {
28596936;
29529526;
49983437;
}

if audio not bannedaudio then

end
3 Likes

Thanks so much for the reply, this is exactly what I was looking for.

I am quite new to scripting so I was quite unsure what to do.

No i am not sure if that would even work, thats why i said “something like this”

Ah, I think it’s the foundation of what I would expect to do anyway.

I will play around with it and see if I am able to get something to work.

Sure, test and failure by yourself not by some tutorial is always the best way to learn.

1 Like

I suppose this is psuedocode, if you want an actual method of checking if the id is within the array then use table.find:

if (table.find(bannedaudio, id)) then

The arguments are just [table, value].

2 Likes

I have tried to play around with some of the code that people have replied with but I haven’t found anything to work.

Here is my code so far:

local bannedaudio = {
ID here;
ID here;
ID here;
}

if (table.find(bannedaudio, id)) then
game.Players.LocalPlayer:Kick("Please don't play crash audios.")
end

I am probably going to come back later/tommorow to see if I can fix it.

You probably shouldn’t use a localscript, use a remote event if needed

I have finally got a temp-fix for this, thanks to all the people who have replied here to help me.

I hope someone finds this useful if they are trying to block certain audios from being played inside their game, which they will be able to figure it out by viewing the past replies.