Making a "The Infection" type game and I'm trying to make it so it plays a random audio everytime humans/zombies win. But when I try, the timer stops and nothing happens. What's wrong in this?
function PickRandomFrom(tab) return tab[math.random(1,#tab)] end local id = PickRandomFrom(225032784,225032798,225032815) local WinMusic = Instance.new("Sound", Game.Workspace) WinMusic.SoundId = "http://www.roblox.com/asset?id=" ..id.. "" WinMusic:Play() wait(15) WinMusic:Remove()
Your error here was with the table, if you want to declare a table you need to put this thing {}
Your code fix here:
local idsSound = {225032784, 225032798, 225032815} function PickRandomFrom(sounds) local randomNumber = math.random(1, #sounds) return sounds[randomNumber] end local id = PickRandomFrom(idsSound) local WinMusic = Instance.new("Sound", workspace) WinMusic.SoundId = "http://www.roblox.com/asset?id=" ..id.. "" WinMusic:Play() wait(15) WinMusic:Remove()