I want a random sound but the Output get me this error
ReplicatedFirst.GameManager:11: bad argument #1 to 'random' (number expected, got table)
local GameManager = { DeathSounds = { 131138839, 131138845, 131138854, }, } function zombieDeathSong(z) local sound = Instance.new('Sound', z) sound.SoundId = 'rbxassetid://'.. math.random(GameManager.DeathSounds) sound:Play() end
You're returning a table, as says kingdom5. To get a random thing inside a table, you do:
sound.SoundId = 'rbxassetid://'..GameManager.DeathSounds[math.random(1,#GameManager.DeathSounds)]
How this works: To access a certain thing inside a table, you do table[number] to access, for example, GameManager.DeathSounds[1] returns 131138839.