In my GUI, I'm creating pages in my menu for the players to see more things about the game. Unfortunately I've tried my best and nothing seems to be working. I'm not sure if I'm tweening the pages incorrectly or maybe it could be the positioning? I'm not sure, any thoughts? The only thing that seems to be working is scrolling down the pages, scrolling back up is where it breaks and shows nothing. (The silly keywords, such as "cheese" or "depression", are tags for the levels in the game, if that throws anyone off)
pagenow = 1 cf = true cheese = UDim2.new(0.100000001, 0,0.100000001, 0) depression = UDim2.new(2, 0, 0.100000001, 0) driving = UDim2.new(3, 0, 0.100000001, 0) thousand = UDim2.new(4, 0, 0.100000001, 0) rub = UDim2.new(5, 0, 0.100000001, 0) function TweenPageTo(page,pos) page:TweenPosition(pos,"Out","Back",.75,true,nil) end function SetPageTo(page,pos) page.Position = pos end function CountPages() --returns table with pages pages = {} for i,v in pairs(script.Parent:GetChildren()) do if v.Name:sub(1,4)=="Page" then pages[#pages+1]=v end end return pages end function GetNext() --returns the next page if pagenow<#CountPages() then return script.Parent["Page".. pagenow+1] else return nil end end function GetPrev() --returns the previous page if pagenow>1 then return script.Parent["Page".. pagenow-1] else return nil end end script.Parent.Frame.NextPage.MouseButton1Down:connect(function() if cf then nextpage = GetNext() if nextpage~=nil then cf = false TweenPageTo(script.Parent["Page".. pagenow],depression) nextpage.Visible = true SetPageTo(nextpage,driving) TweenPageTo(nextpage,cheese) wait(.75) script.Parent["Page".. pagenow].Visible = false pagenow = pagenow + 1 cf = true end end end) script.Parent.Frame.PrevPage.MouseButton1Down:connect(function() if cf then prevpage = GetPrev() if prevpage~=nil then cf = false TweenPageTo(script.Parent["Page".. pagenow],driving) prevpage.Visible = true SetPageTo(prevpage,depression) TweenPageTo(nextpage,thousand) wait(.75) script.Parent["Page".. pagenow].Visible = false pagenow = pagenow - 1 cf = true end end end) script.Parent.Frame.PrevPage.MouseButton1Down:connect(function() if cf then prevpage = GetPrev() if prevpage~=nil then cf = false TweenPageTo(script.Parent["Page".. pagenow],thousand) prevpage.Visible = true SetPageTo(prevpage,driving) TweenPageTo(nextpage,rub) wait(.75) script.Parent["Page".. pagenow].Visible = false pagenow = pagenow - 1 cf = true end end end) script.Parent.Frame.PrevPage.MouseButton1Down:connect(function() if cf then prevpage = GetPrev() if prevpage~=nil then cf = false TweenPageTo(script.Parent["Page".. pagenow],rub) prevpage.Visible = true SetPageTo(prevpage,thousand) TweenPageTo(prevpage,cheese) TweenPageTo(prevpage,depression) TweenPageTo(prevpage,driving) wait(.75) script.Parent["Page".. pagenow].Visible = false pagenow = pagenow - 1 cf = true end end end)