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

Having trouble with a music change/toggle script?

Asked by
djwchon 10
3 years ago

Here is the code I have, I don't know why it isn't working.

Brick = script.Parent
ch1 = Brick.Channel_1
ch2 = Brick.Channel_2

function onClicked()
    if Brick.On.Value == false then
        Brick.On.Value = true
    elseif Brick.On.Value == true then
        Brick.On.Value = false
        if script.Parent.Channel.Value == "ch1" and Brick.On.Value == true then
            Brick.Channel_1:Play()
        elseif script.Parent.Channel.Value == "ch2" and Brick.On.Value == true then
            Brick.Channel_2:Play()
        else
            Brick.Channel_1:Stop()
            Brick.Channel_2:Stop()
        end
    end
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)

1 answer

Log in to vote
0
Answered by
djwchon 10
3 years ago

Answered!

Ad

Answer this question