SHOW:
|
|
- or go back to the newest paste.
| 1 | local module = {}
| |
| 2 | local tweenService = game:GetService("TweenService")
| |
| 3 | ||
| 4 | ||
| 5 | local screenGui = script.Parent:WaitForChild("ScreenGui")
| |
| 6 | ||
| 7 | ||
| 8 | local OpenSpeed = 0.8 | |
| 9 | local CloseSpeed = 0.2 | |
| 10 | ||
| 11 | ||
| 12 | local OpenEasingStyle = Enum.EasingStyle.Back | |
| 13 | local OpenEasingDirection = Enum.EasingDirection.Out | |
| 14 | ||
| 15 | ||
| 16 | local ClosingEasingStyle = Enum.EasingStyle.Sine | |
| 17 | local ClosingEasingDirection = Enum.EasingDirection.Out | |
| 18 | ||
| 19 | ||
| 20 | function module.GetFrame(frameName) | |
| 21 | local frames = screenGui:GetDescendants() | |
| 22 | local frame = nil | |
| 23 | ||
| 24 | ||
| 25 | for i, item in pairs(frames) do | |
| 26 | if item.Name == frameName then | |
| 27 | frame = item | |
| 28 | end | |
| 29 | end | |
| 30 | ||
| 31 | return frame | |
| 32 | end | |
| 33 | ||
| 34 | ||
| 35 | ||
| 36 | ||
| 37 | function module.OpenFrame(frameName) | |
| 38 | ||
| 39 | ||
| 40 | local frame = module.GetFrame(frameName) | |
| 41 | ||
| 42 | ||
| 43 | if frame then | |
| 44 | local normalSize = frame.Size | |
| 45 | frame.Size = UDim2.fromScale(0, 0) | |
| 46 | task.wait(CloseSpeed + 0.1) | |
| 47 | frame.Visible = true | |
| 48 | ||
| 49 | ||
| 50 | local openTween = tweenService:Create( | |
| 51 | frame, | |
| 52 | TweenInfo.new( | |
| 53 | OpenSpeed, | |
| 54 | OpenEasingStyle, | |
| 55 | OpenEasingDirection), | |
| 56 | {
| |
| 57 | Size = normalSize | |
| 58 | } | |
| 59 | ) | |
| 60 | ||
| 61 | ||
| 62 | openTween:Play() | |
| 63 | end | |
| 64 | end | |
| 65 | ||
| 66 | ||
| 67 | function module.CloseFrame(frameName) | |
| 68 | ||
| 69 | local frame = module.GetFrame(frameName) | |
| 70 | ||
| 71 | if frame then | |
| 72 | local normalSize = frame.Size | |
| 73 | local closeTween = tweenService:Create( | |
| 74 | frame, | |
| 75 | TweenInfo.new( | |
| 76 | CloseSpeed, | |
| 77 | ClosingEasingStyle, | |
| 78 | ClosingEasingDirection), | |
| 79 | {
| |
| 80 | Size = UDim2.fromScale(0, 0) | |
| 81 | } | |
| 82 | ) | |
| 83 | closeTween:Play() | |
| 84 | closeTween.Completed:Connect(function() | |
| 85 | frame.Visible = false | |
| 86 | frame.Size = normalSize | |
| 87 | end) | |
| 88 | end | |
| 89 | end | |
| 90 | ||
| 91 | ||
| 92 | for _, v in pairs(screenGui:GetDescendants()) do | |
| 93 | if v:IsA("GuiButton") then
| |
| 94 | if v:FindFirstChild("Opens") then
| |
| 95 | if v:FindFirstChild("Opens").Value ~= nil then
| |
| 96 | v.MouseButton1Click:Connect(function() | |
| 97 | module.OpenFrame(v:FindFirstChild("Opens").Value.Name)
| |
| 98 | end) | |
| 99 | end | |
| 100 | end | |
| 101 | if v:FindFirstChild("Closes") then
| |
| 102 | if v:FindFirstChild("Closes").Value ~= nil then
| |
| 103 | v.MouseButton1Click:Connect(function() | |
| 104 | module.CloseFrame(v:FindFirstChild("Closes").Value.Name)
| |
| 105 | end) | |
| 106 | end | |
| 107 | end | |
| 108 | end | |
| 109 | end | |
| 110 | ||
| 111 | ||
| 112 | return module |