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

Next arrow will work JUST FINE but then back arrow is unresponsive, how do I get it to work?

Asked by
popeeyy 493 Moderation Voter
6 years ago
Edited 6 years ago

I'm making a selection gui that goes forward and back but the gui keeps glitching out. I'm trying to change a value to know what the next gui is and the old one to not be visible anymore. Can anyone help? It will NOT go back at all but it goes next. Next:

--next
    local gui= script.Parent.Parent.Flights


script.Parent.MouseButton1Click:connect(function()


local old= gui.Old.Value
    local gui= script.Parent.Parent.Flights
    local max= gui.Max.Value
    local min= gui.Min.Value
    local now= gui.Current.Value
    local flights= gui.Flights
    script.now.Value= script.now.Value+1
    gui.Current.Value= script.now.Value
    print(now)

    if now > max then
old= now-1
        script.now.Value= min
    now= script.now.Value
            print("bad")
        local curfli= flights:FindFirstChild("F"..now)
        local oldfli= flights:FindFirstChild("F"..old)
            if oldfli orcurfli ~= nil then
        curfli.Visible=true
        oldfli.Visible=false
            script.Parent.Parent.Page.Text= now.." / "..max         
end
    elseif now > min or now == min  then
    print("good")
old= now-1
        local curfli= flights:FindFirstChild("F"..now)
        local oldfli= flights:FindFirstChild("F"..old)
            if oldfli or curfli ~= nil then
        curfli.Visible=true
        oldfli.Visible=false
script.Parent.Parent.Page.Text= now.." / "..max     
end
    end


end)

Back:

--back
    local gui= script.Parent.Parent.Flights


script.Parent.MouseButton1Click:connect(function()
local old= gui.Old.Value
    local gui= script.Parent.Parent.Flights
    local max= gui.Max.Value
    local min= gui.Min.Value
    local now= gui.Current.Value
    local flights= gui.Flights
    now= now-1

    print("new"..now)
    print("old"..old)
if now == 0 or now > max then
    print("NO")

    now= 1
    old= 2  
        local oldf= flights:FindFirstChild("F"..old)
    local nowf= flights:FindFirstChild("F"..now)
        if oldf or nowf ~= nil then
    script.Parent.Parent.Page.Text= now.." / "..max 
    oldf.Visible=false
    nowf.Visible=true   
    end
else
    old= now+1
    print("ya")
    local oldf= flights:FindFirstChild("F"..old)
    local nowf= flights:FindFirstChild("F"..now)
    if oldf or nowf ~= nil then
    oldf.Visible=false
    nowf.Visible=true
    script.Parent.Parent.Page.Text= now.." / "..max     
    end
end
end)

1 answer

Log in to vote
0
Answered by 6 years ago
currentIndex = 1
FramesHolder = insert frames holder

NextButton.MouseButton1Click:connect(function()
    currentIndex = currentIndex + 1
    if currentIndex > #FramesHolder:GetChildren() then
        currentIndex = 1
    end
    for i,v in pairs(FramesHolder:children()) do
        v.Visible = false
    end
    FramesHolder["Flight" .. currentIndex].Visible = true
end)

BackButton.MouseButton1Click:connect(function()
    currentIndex = currentIndex - 1
    if currentIndex == 0 then
        currentIndex = #FramesHolder:GetChildren()
    end
    for i,v in pairs(FramesHolder:children()) do
        v.Visible = false
    end
    FramesHolder["Flight" .. currentIndex].Visible = true
end)
Ad

Answer this question