I'm trying to make this script play random music each time, But It Won't Work any Suggestions or ideas? What did I do wrong?
X = (math.random(1,5)) function onPlayerAdded(newPlayer) if X == 1 then script.Parent.menu_sfx_audio.SoundId = "http://www.roblox.com/asset/?id=199768665" wait(.5) script.Parent.menu_sfx_audio:Play() elseif X == 2 then script.Parent.menu_sfx_audio.SoundId = "http://www.roblox.com/asset/?id=199768665" wait(.5) script.Parent.menu_sfx_audio:Play() elseif X == 3 then script.Parent.menu_sfx_audio.SoundId = "http://www.roblox.com/asset/?id=199768665" wait(.5) script.Parent.menu_sfx_audio:Play() elseif X == 4 then script.Parent.menu_sfx_audio.SoundId = "http://www.roblox.com/asset/?id=167135038" wait(.5) script.Parent.menu_sfx_audio:Play() elseif X == 5 then script.Parent.menu_sfx_audio.SoundId = "http://www.roblox.com/asset/?id=185601181" wait(.5) script.Parent.menu_sfx_audio:Play() end game.Players.PlayerAdded:connect(onPlayerAdded)