Cakey3101

Legends Of Speed - 8 - GuiController

Sep 19th, 2025 (edited)
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.56 KB | Source Code | 0 0
  1. local Players = game:GetService("Players")
  2. local Lighting = game:GetService("Lighting")
  3. local Workspace = game:GetService("Workspace")
  4. local TweenService = game:GetService("TweenService")
  5.  
  6. local Blur = Lighting:FindFirstChild("Blur") or Instance.new("BlurEffect")
  7. Blur.Name = "Blur"
  8. Blur.Parent = Lighting
  9. Blur.Size = 0
  10.  
  11. local Camera = Workspace.CurrentCamera
  12. local Player = Players.LocalPlayer
  13. local PlayerGui = Player:WaitForChild("PlayerGui")
  14.  
  15. local GuiController = {}
  16.  
  17. GuiController.Guis = {
  18.     Top = PlayerGui:WaitForChild("Top"),
  19.     Left = PlayerGui:WaitForChild("Left"),
  20.     Right = PlayerGui:WaitForChild("Right"),
  21.     Help = PlayerGui:WaitForChild("Help"),
  22.     Codes = PlayerGui:WaitForChild("Codes"),
  23. }
  24.  
  25. GuiController.CurrentOpenGui = nil
  26.  
  27. function GuiController.SetupGui(ScreenGui, OpenButton, ExitButton)
  28.     local Frame = ScreenGui:WaitForChild("Frame")
  29.     if not Frame then
  30.         return
  31.     end
  32.  
  33.     Frame.Visible = false
  34.  
  35.     local function ToggleGui()
  36.         if GuiController.CurrentOpenGui == ScreenGui then
  37.             local BasicInfo = TweenInfo.new(0.5, Enum.EasingStyle.Back, Enum.EasingDirection.InOut)
  38.  
  39.             local BlurTween = TweenService:Create(Blur, BasicInfo, {Size = 0})
  40.             BlurTween:Play()
  41.  
  42.             local CameraTween = TweenService:Create(Camera, BasicInfo, {FieldOfView = 70})
  43.             CameraTween:Play()
  44.  
  45.             Frame.Visible = false
  46.             GuiController.CurrentOpenGui = nil
  47.         else
  48.             if GuiController.CurrentOpenGui then
  49.                 local CurrentFrame = GuiController.CurrentOpenGui:FindFirstChild("Frame")
  50.                 if CurrentFrame then
  51.                     CurrentFrame.Visible = false
  52.                 end
  53.             end
  54.  
  55.             GuiController.CurrentOpenGui = ScreenGui
  56.             Frame.Visible = true
  57.  
  58.             local BasicInfo = TweenInfo.new(0.5, Enum.EasingStyle.Back, Enum.EasingDirection.InOut)
  59.  
  60.             local BlurTween = TweenService:Create(Blur, BasicInfo, {Size = 24})
  61.             BlurTween:Play()
  62.  
  63.             local CameraTween = TweenService:Create(Camera, BasicInfo, {FieldOfView = 50})
  64.             CameraTween:Play()
  65.         end
  66.     end
  67.  
  68.     OpenButton.MouseButton1Click:Connect(ToggleGui)
  69.     ExitButton.MouseButton1Click:Connect(ToggleGui)
  70. end
  71.  
  72. function GuiController.CloseAllGuis()
  73.     for _, Gui in pairs(GuiController.Guis) do
  74.         local Frame = Gui:FindFirstChild("Frame")
  75.         if Frame then
  76.             Frame.Visible = false
  77.         end
  78.     end
  79.  
  80.     local BasicInfo = TweenInfo.new(0.5, Enum.EasingStyle.Back, Enum.EasingDirection.InOut)
  81.  
  82.     local BlurTween = TweenService:Create(Blur, BasicInfo, {Size = 0})
  83.     BlurTween:Play()
  84.  
  85.     local CameraTween = TweenService:Create(Camera, BasicInfo, {FieldOfView = 70})
  86.     CameraTween:Play()
  87.  
  88.     GuiController.CurrentOpenGui = nil
  89. end
  90.  
  91. return GuiController
Advertisement
Add Comment
Please, Sign In to add comment