Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Changeable variables (settings).
- local TotalPages = 4 -- How many total pages are there.
- local SlidingEffect = true -- If true, the pages will slide, with any speed you input in the "SlidingSpeed" variable.
- local SlidingSpeed = 0.5 -- Page sliding speed. If "SlidingEffect" is on, this will take place.
- -- Unchangeable variables.
- local CurrentPage = 1
- local CanUseNext = true
- local CanUsePrevious = false
- -- Main Variables.
- local UI = script.Parent -- The gui.
- local PagesList = UI.List -- The frame that holds all pages.
- local Next = UI.Next -- The "next" button.
- local Previous = UI.Previous -- The "previous" button.
- -- Functions.
- function UpdateVariables()
- if CurrentPage == TotalPages then
- CanUseNext = false
- elseif CurrentPage == 1 then
- CanUsePrevious = false
- end
- if PagesList:FindFirstChild("Page".. (CurrentPage - 1)) then
- CanUsePrevious = true
- elseif PagesList:FindFirstChild("Page".. (CurrentPage + 1)) then
- CanUseNext = true
- end
- end
- UpdateVariables()
- Next.MouseButton1Click:Connect(function()
- if PagesList:FindFirstChild("Page".. (CurrentPage + 1)) and CanUseNext == true then
- if SlidingEffect == true then
- PagesList:FindFirstChild("Page".. CurrentPage):TweenPosition(UDim2.new(-1, 0, 0, 0), "Out", "Quad", SlidingSpeed, true) -- Slide to the left (off the screen).
- else
- PagesList:FindFirstChild("Page".. CurrentPage).Position = UDim2.new(-1, 0, 0, 0) -- Off the screen (no sliding effect).
- end
- CurrentPage = CurrentPage + 1
- if SlidingEffect == true then
- PagesList:FindFirstChild("Page".. CurrentPage):TweenPosition(UDim2.new(0, 0, 0, 0), "Out", "Quad", SlidingSpeed, true) -- Slide to the center.
- else
- PagesList:FindFirstChild("Page".. CurrentPage).Position = UDim2.new(0, 0, 0, 0) -- In the center (no sliding effect).
- end
- UpdateVariables()
- end
- end)
- Previous.MouseButton1Click:Connect(function()
- if PagesList:FindFirstChild("Page".. (CurrentPage - 1)) and CanUsePrevious == true then
- if SlidingEffect == true then
- PagesList:FindFirstChild("Page".. CurrentPage):TweenPosition(UDim2.new(1, 0, 0, 0), "Out", "Quad", SlidingSpeed, true) -- Slide to the right (off the screen).
- else
- PagesList:FindFirstChild("Page".. CurrentPage).Position = UDim2.new(1, 0, 0, 0) -- Off the screen (no sliding effect).
- end
- CurrentPage = CurrentPage - 1
- if SlidingEffect == true then
- PagesList:FindFirstChild("Page".. CurrentPage):TweenPosition(UDim2.new(0, 0, 0, 0), "Out", "Quad", SlidingSpeed, true) -- Slide to the center.
- else
- PagesList:FindFirstChild("Page".. CurrentPage).Position = UDim2.new(0, 0, 0, 0) -- In the center (no sliding effect).
- end
- UpdateVariables()
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement