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

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

Asked by 7 years ago
Edited 7 years ago

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
their is no such thing as random.math :P greatneil80 2647 — 7y

2 answers

Log in to vote
1
Answered by 7 years ago

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

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. LisaF854 93 — 7y
0
unlike many other programmig languages, LUA does not loop the same script over and over. LisaF854 93 — 7y
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 greatneil80 2647 — 7y
Ad
Log in to vote
0
Answered by 7 years ago

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.

Answer this question