Advertisement
ur9rgi

RTS - FlowMasterV1 I AnnounceHandle

Sep 29th, 2024
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.72 KB | None | 0 0
  1. local TweenService = game:GetService("TweenService")
  2. local LoadingBar = script.Parent.Progress
  3. local MainFrame = script.Parent.Parent.Announcement
  4.  
  5. local function tweenPosition(object, targetPosition, duration)
  6.     local tweenInfo = TweenInfo.new(duration, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
  7.     local tween = TweenService:Create(object, tweenInfo, {Position = targetPosition})
  8.     tween:Play()
  9. end
  10.  
  11. local function tweenSize(object, targetSize, duration)
  12.     local tweenInfo = TweenInfo.new(duration, Enum.EasingStyle.Linear, Enum.EasingDirection.Out)
  13.     local tween = TweenService:Create(object, tweenInfo, {Size = targetSize})
  14.     tween:Play()
  15. end
  16.  
  17. game.ReplicatedStorage["RTS FlowMaster V1"].GateUpdate.OnClientEvent:Connect(function(gate, esttime)
  18.     -- Ensure esttime is a number
  19.     esttime = tonumber(esttime)
  20.  
  21.     if esttime and esttime > 0 then
  22.         -- Tween to make MainFrame visible (updated in-view position)
  23.         tweenPosition(MainFrame, UDim2.new(0, 129, 0, 47), 0.5)
  24.  
  25.         -- Set initial text
  26.         script.Parent.Title.Text = "FlowMaster queue time updated"
  27.         script.Parent.Content.Text = "The door/gate " .. gate .. " wait time has been updated! The current estimated wait time from the start is " .. esttime .. " seconds."
  28.  
  29.         -- Reset progress bar to initial size
  30.         LoadingBar.Size = UDim2.new(0, 1, 0, 20)
  31.  
  32.         -- Tween progress bar to full size based on esttime
  33.         tweenSize(LoadingBar, UDim2.new(0, 1030, 0, 20), esttime)
  34.  
  35.         -- Wait for the estimated time, then tween to hide MainFrame
  36.         wait(5)
  37.  
  38.         tweenPosition(MainFrame, UDim2.new(0.101, 0, -0.2, 0), 0.5)
  39.  
  40.         -- Reset progress bar size after hiding the frame
  41.         LoadingBar.Size = UDim2.new(0, 1, 0, 20)
  42.     else
  43.         warn("Invalid estimated time: " .. tostring(esttime))
  44.     end
  45. end)
  46.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement