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

Why doesn't my script work?

Asked by 9 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

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)


3
line 1 should be switched with line two so that it is in the function LostPast 253 — 9y
0
I would also put in; math.randomseed(tick()) to make stuff more random ;D MessorAdmin 598 — 9y
0
Can you provide a list of the full hierarchy please? Goulstem 8144 — 9y

Answer this question