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

Is This Script Correct? (Song Playing Button)

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 created a script in the StarterGui, and the parent of the script is a TextButton, and the parent of that is a ScreenGui, the screengui includes a Sound too. I am trying to make a button that when you click it it plays the song in the sound id. Although it's not working, this is the script of the TextButton. (It's a LocalScript)

Player = game.Players.LocalPlayer
Button = script.Parent
Song = script.Parent.Parent.Song
Playing = false

function PlaySong()
    if (Playing == false) then
        Song:Play()
        Playing = true
    elseif (Playing == true) then
        Song:Stop()
        Playing = false
    end
end

Button.MouseButton1Down:connect(PlaySong)
0
Could be a loading issue. Try preloading the song asset. Validark 1580 — 9y
0
Oh and by the way, I forgot to say, it works when I test in ROBLOX Studio, but not in server IBuildOn 15 — 9y

1 answer

Log in to vote
-2
Answered by 9 years ago

Use click detector.

Ad

Answer this question