Cakey3101

Tween Gui Module

May 6th, 2025
437
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.38 KB | Source Code | 0 0
  1. local Players = game:GetService("Players")
  2. local Lighting = game:GetService("Lighting")
  3. local TweenService = game:GetService("TweenService")
  4.  
  5. local BlurEffect = Lighting:WaitForChild("Blur")
  6.  
  7. local Player = Players.LocalPlayer
  8. local PlayerGui = Player.PlayerGui
  9.  
  10. local TweenGui = {}
  11.  
  12. function TweenGui.OpenGui(Gui: ScreenGui, Frame: Frame)
  13.     for _, ScreenGui in PlayerGui:GetChildren() do
  14.         if ScreenGui:IsA("ScreenGui") then
  15.             if ScreenGui.Name ~= Gui.Name then
  16.                 ScreenGui.Enabled = false
  17.                
  18.                 Gui.Enabled = true
  19.                 BlurEffect.Enabled = true
  20.                 local BlurTween = TweenService:Create(BlurEffect, TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.In), {Size = 24}):Play()
  21.                 Frame:TweenPosition(UDim2.fromScale(0.5, 0.5), Enum.EasingDirection.InOut, Enum.EasingStyle.Sine, 1)
  22.             end
  23.         end
  24.     end
  25. end
  26.  
  27. function TweenGui.CloseGui(Gui: ScreenGui, Frame: Frame)
  28.     Frame:TweenPosition(UDim2.fromScale(0.5, -2), Enum.EasingDirection.InOut, Enum.EasingStyle.Sine, 1)
  29.     local BlurTween = TweenService:Create(BlurEffect, TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.Out), {Size = 0}):Play()
  30.     task.wait(0.5)
  31.     BlurEffect.Enabled = false
  32.     Gui.Enabled = false
  33.    
  34.     for _, ScreenGui in PlayerGui:GetChildren() do
  35.         if ScreenGui:IsA("ScreenGui") then
  36.             if ScreenGui.Name == "Main" then
  37.                 ScreenGui.Enabled = true
  38.             end
  39.         end
  40.     end
  41. end
  42.  
  43. return TweenGui
Tags: robloxstudio
Advertisement
Add Comment
Please, Sign In to add comment