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

How do I fix the problem with script listing? Seems like I did something wrong

Asked by 4 years ago

I wanted to make simple frame switch with arrows, but whenever I press arrow, it completes all "if"'s, I checked it with debug, when I press button it does "1,2,3" here is the code.

--buttons//
local L = script.parent.Title.LArrow
local R = script.Parent.Title.RArrow
--texts//
local v1 = script.Parent.Title.Texts.Video
local a1 = script.Parent.Title.Texts.Audio
local i1 = script.Parent.Title.Texts.Audio
--SetsScreens//
local v2 = script.Parent.Sets.Video
local a2 = script.Parent.Sets.Audio
local i2 = script.Parent.Sets.Audio
--Variables//
local list = 1

--Main//
local function RPress()
    if list == 1 then
        print(list)
        list = 2
    end
    if list == 2 then
        print(list)
        list = 3
    end
    if list == 3 then
        print(list)
        list = 1
    end
end

local function LPress()
    if list == 1 then
        print(list)
        list = 3
    end
    if list == 2 then
        print(list)
        list = 1
    end
    if list == 3 then
        print(list)
        list = 2
    end
end
L.MouseButton1Click:Connect(LPress)
R.MouseButton1Click:Connect(RPress)

Answer this question