New Coder, Help Debugging a Surface GUI That Plays Music?
Asked by
6 years ago Edited 6 years ago
Hi! I'm just now dabbling in ROBLOX programming (with no prior coding knowledge) so my code will be very crude, so bear with me.
I'm creating a surface GUI that has a large image button in the middle, and two image buttons on either side to cycle the middle image. I don't know the best way to do this, so so far I have a script in the left and right buttons that increases or decreases a _G variable by one every time you click. It looks like this:
1 | script.Parent.MouseButton 1 Click:connect( function () |
Then I have another script in the big central image button that is supposed to detect if the _G variable equals either 1 or 2, and plays a different song on click depending on the value of the variable. The code looks like this:
01 | mus 1 = workspace.juke.buttons.music 1 |
02 | mus 2 = workspace.juke.buttons.music 2 |
07 | script.Parent.MouseButton 1 Click:connect( function (one) |
10 | elseif _G.song = = 2 then |
11 | script.Parent.MouseButton 1 Click:connect( function (two) |
When I click the big central button however, it plays both songs, not one or the other. Why is it playing both?