Advertisement
Enc0ded

Untitled

Jan 22nd, 2019
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.65 KB | None | 0 0
  1. -- Changeable variables (settings).
  2. local TotalPages = 4 -- How many total pages are there.
  3. local SlidingEffect = true -- If true, the pages will slide, with any speed you input in the "SlidingSpeed" variable.
  4. local SlidingSpeed = 0.5 -- Page sliding speed. If "SlidingEffect" is on, this will take place.
  5.  
  6. -- Unchangeable variables.
  7. local CurrentPage = 1
  8. local CanUseNext = true
  9. local CanUsePrevious = false
  10.  
  11. -- Main Variables.
  12. local UI = script.Parent -- The gui.
  13. local PagesList = UI.List -- The frame that holds all pages.
  14. local Next = UI.Next -- The "next" button.
  15. local Previous = UI.Previous -- The "previous" button.
  16.  
  17. -- Functions.
  18. function UpdateVariables()
  19.     if CurrentPage == TotalPages then
  20.         CanUseNext = false
  21.     elseif CurrentPage == 1 then
  22.         CanUsePrevious = false
  23.     end
  24.     if PagesList:FindFirstChild("Page".. (CurrentPage - 1)) then
  25.         CanUsePrevious = true
  26.     elseif PagesList:FindFirstChild("Page".. (CurrentPage + 1)) then
  27.         CanUseNext = true
  28.     end
  29. end
  30.  
  31. UpdateVariables()
  32. Next.MouseButton1Click:Connect(function()
  33.     if PagesList:FindFirstChild("Page".. (CurrentPage + 1)) and CanUseNext == true then
  34.         if SlidingEffect == true then
  35.             PagesList:FindFirstChild("Page".. CurrentPage):TweenPosition(UDim2.new(-1, 0, 0, 0), "Out", "Quad", SlidingSpeed, true) -- Slide to the left (off the screen).
  36.         else
  37.             PagesList:FindFirstChild("Page".. CurrentPage).Position = UDim2.new(-1, 0, 0, 0) -- Off the screen (no sliding effect).
  38.         end
  39.         CurrentPage = CurrentPage + 1
  40.         if SlidingEffect == true then
  41.             PagesList:FindFirstChild("Page".. CurrentPage):TweenPosition(UDim2.new(0, 0, 0, 0), "Out", "Quad", SlidingSpeed, true) -- Slide to the center.
  42.         else
  43.             PagesList:FindFirstChild("Page".. CurrentPage).Position = UDim2.new(0, 0, 0, 0) -- In the center (no sliding effect).
  44.         end
  45.         UpdateVariables()
  46.     end
  47. end)
  48. Previous.MouseButton1Click:Connect(function()
  49.     if PagesList:FindFirstChild("Page".. (CurrentPage - 1)) and CanUsePrevious == true then
  50.         if SlidingEffect == true then
  51.             PagesList:FindFirstChild("Page".. CurrentPage):TweenPosition(UDim2.new(1, 0, 0, 0), "Out", "Quad", SlidingSpeed, true) -- Slide to the right (off the screen).
  52.         else
  53.             PagesList:FindFirstChild("Page".. CurrentPage).Position = UDim2.new(1, 0, 0, 0) -- Off the screen (no sliding effect).
  54.         end
  55.         CurrentPage = CurrentPage - 1
  56.         if SlidingEffect == true then
  57.             PagesList:FindFirstChild("Page".. CurrentPage):TweenPosition(UDim2.new(0, 0, 0, 0), "Out", "Quad", SlidingSpeed, true) -- Slide to the center.
  58.         else
  59.             PagesList:FindFirstChild("Page".. CurrentPage).Position = UDim2.new(0, 0, 0, 0) -- In the center (no sliding effect).
  60.         end
  61.         UpdateVariables()
  62.     end
  63. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement