Can someone tell me how to make this script randomly pick a Id from the ValidIds
table and change the SoundId
to that?
local ValidIds = {"206068135","180477573"} while wait(3) do script.Parent:Stop() for i,v in pairs(ValidIds) do script.Parent.SoundId = "rbxassetid://"..v script.Parent:Play() end end
Compliments of Validark, here is the application
local ValidIds = {"206068135","180477573"} while wait(3) do script.Parent:Stop() local randomSound = math.random(1, #ValidIds) -- Pick a number between 1 and the number of ValidIds randomSound = ValidIds[randomSound] -- Find the selected value in the table script.Parent.SoundId = "rbxassetid://"..randomsound script.Parent:Play() end
Use math.random
. More information on that here.
local randomSound = math.random(1, #ValidIds) -- Pick a number between 1 and the number of ValidIds randomSound = ValidIds[randomSound] -- Find the selected value in the table