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

why wont this script work?

Asked by 10 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.
function Click()
    Game.StarterGui.Music.SoundId = "rbxassetid://142478510"
    Game.StarterGui.Music:Play()
    wait(120)
    Game.StarterGui.Music.SoundId = "rbxassetid://142478390"
    Game.StarterGui.Music:Play()
end
script.Parent.MouseButton1Down:connect(Click)

1 answer

Log in to vote
1
Answered by
Merely 2122 Moderation Voter Community Moderator
10 years ago

The StarterGui is just a container for GUI objects. When a player spawns, the items in StarterGui are copied into the player's PlayerGui. So if you play a Sound in StarterGui, no one will hear it.

Assuming this is a LocalScript, and you put it inside your GUI, you should be playing the "Music" sound object that exists in the script's parent.

e.g.

    local music = script.Parent.Music
    music.SoundId = "rbxassetid://142478510"
    music:Play()
Ad

Answer this question