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

When a Zombie Dies Plays a list of sound but its math.random?

what i am trying to say that theres a zombie and when i kill it or when it dies it plays a sound from a list of sounds in the script like this

{ID,ID,ID,ID}--When Zombie Dies Plays one of the random sound id's

1 comment

1

their is no such thing as random.math :P

2 answers

this plays a random song id whenever a zombie dies..

math.randomseed(tick()) -- makes sure when you constantly replay the game, their will be a different sound
local Zombie = -- your zombie's head...
if Zombie == nil then
local a = -- Song ID
local b = -- Song ID
local c = -- Song ID
local d = -- Song ID
local e = -- Song ID

local ZombieVoice = Instance.new("Sound", Zombie)
ZombieVoice.SoundId = math.random(a,b,c,d,e)


end

I hope this worked, thank you if you accept answer

3 comments

0

this wont work, it will run this once as soon as the server starts, and only once, if a zombie does not die at the moment it runs, nothing will happen.

0

unlike many other programmig languages, LUA does not loop the same script over and over.

1

I know idiot, he made me go to his team create and i made the script so shut up, i am f... pissed rn.. i used a while wait() do, now please get those comments out of the chat, they are bugging the crap outta me

math.random

Perhaps, putting the variables [of sounds] on a table. In which, you can use that math.random with respect to the table you just implemented.

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