Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if not game:IsLoaded() then
- game.Loaded:Wait()
- end
- local Player = game:GetService("Players").LocalPlayer
- local Mouse = Player:GetMouse()
- local TweenService, TextService, RunService, StatService = game:GetService("TweenService"), game:GetService("TextService"), game:GetService("RunService"), game:GetService("Stats")
- local TargetParent = RunService:IsStudio() and Player.PlayerGui or game:GetService("CoreGui")
- return function(Settings)
- local Settings = (typeof(Settings) == "table") and Settings or {
- ScriptName = "Utilities",
- Timer = true,
- FPS = true,
- Decimals = 0,
- CacheSize = 10,
- Center = true
- }
- Settings.ScriptName = Settings.ScriptName or "Utilities"
- Settings.Timer = (typeof(Settings.Timer) == "boolean") and Settings.Timer or false
- Settings.FPS = (typeof(Settings.FPS) == "boolean") and Settings.FPS or false
- Settings.Decimals = Settings.Decimals or 0
- Settings.CacheSize = Settings.CacheSize or 10
- Settings.Center = (typeof(Settings.Center) == "boolean") and Settings.Center or false
- local OldInstance = TargetParent:FindFirstChild(Settings.ScriptName)
- pcall(function() OldInstance:Destroy() end)
- local NewInstance = Instance.new("ScreenGui")
- NewInstance.Name = Settings.ScriptName
- NewInstance.Parent = TargetParent
- local Container = Instance.new("Frame")
- Container.Name = "Container"
- Container.BackgroundTransparency = 1
- Container.Size = UDim2.fromScale(0,0) + UDim2.fromOffset(0,22)
- Container.Position = (Settings.Center) and UDim2.new(0.5, 0, 0, -26) or UDim2.new(1, 0, 0, -26)
- Container.Parent = NewInstance
- local List = Instance.new("UIListLayout")
- List.FillDirection = Enum.FillDirection[Settings.Center and "Vertical" or "Horizontal"]
- List.HorizontalAlignment = Enum.HorizontalAlignment.Right
- List.SortOrder = Enum.SortOrder.Name
- List.Padding = UDim.new(0,4)
- List.Parent = Container
- local function AlignContainer()
- local ACS = List.AbsoluteContentSize
- local CSX = ACS.X
- Container.Size = UDim2.fromOffset(CSX, 22)
- Container.Position = (Settings.Center) and UDim2.new(0.5, 0, 0, -26) or UDim2.new(1, -(CSX + 55), 0, -26)
- end
- List:GetPropertyChangedSignal("AbsoluteContentSize"):Connect(AlignContainer)
- if Settings.Timer then
- local Timer = Instance.new("Frame")
- Timer.Name = Settings.Center and "1" or "2"
- Timer.BorderSizePixel = 0
- Timer.BackgroundColor3 = Color3.fromRGB(30,30,30)
- Timer.Size = UDim2.fromOffset(123,22)
- Timer.Parent = Container
- local TimerList = Instance.new("UIListLayout")
- TimerList.FillDirection = Enum.FillDirection.Horizontal
- TimerList.Padding = UDim.new(0,1)
- TimerList.VerticalAlignment = Enum.VerticalAlignment.Center
- TimerList.Parent = Timer
- local Hours = Instance.new("Frame")
- Hours.Name = "Hours"
- Hours.Size = UDim2.fromScale(0,1) + UDim2.fromOffset(40,-2)
- Hours.BackgroundColor3 = Color3.fromRGB(40,40,40)
- Hours.BorderSizePixel = 0
- Hours.ClipsDescendants = true
- Hours.Parent = Timer
- local Minutes = Instance.new("Frame")
- Minutes.Name = "Minutes"
- Minutes.Size = UDim2.fromScale(0,1) + UDim2.fromOffset(40,-2)
- Minutes.BackgroundColor3 = Color3.fromRGB(40,40,40)
- Minutes.BorderSizePixel = 0
- Minutes.ClipsDescendants = true
- Minutes.Parent = Timer
- local Seconds = Instance.new("Frame")
- Seconds.Name = "Seconds"
- Seconds.Size = UDim2.fromScale(0,1) + UDim2.fromOffset(40,-2)
- Seconds.BackgroundColor3 = Color3.fromRGB(40,40,40)
- Seconds.BorderSizePixel = 0
- Seconds.ClipsDescendants = true
- Seconds.Parent = Timer
- local OldHour, OldMinute, OldSecond = 0, 0, 0
- local NewHour = Instance.new("TextLabel")
- NewHour.Name = "Old"
- NewHour.Text = OldHour
- NewHour.Size = UDim2.fromScale(1,1)
- NewHour.Font = Enum.Font.Gotham
- NewHour.TextColor3 = Color3.fromRGB(255,255,255)
- NewHour.TextSize = 12
- NewHour.BackgroundTransparency = 1
- NewHour.Parent = Hours
- local NewMinute = Instance.new("TextLabel")
- NewMinute.Name = "Old"
- NewMinute.Text = OldMinute
- NewMinute.Size = UDim2.fromScale(1,1)
- NewMinute.Font = Enum.Font.Gotham
- NewMinute.TextColor3 = Color3.fromRGB(255,255,255)
- NewMinute.TextSize = 12
- NewMinute.BackgroundTransparency = 1
- NewMinute.Parent = Minutes
- local NewSecond = Instance.new("TextLabel")
- NewSecond.Name = "Old"
- NewSecond.Text = OldSecond
- NewSecond.Size = UDim2.fromScale(1,1)
- NewSecond.Font = Enum.Font.Gotham
- NewSecond.TextColor3 = Color3.fromRGB(255,255,255)
- NewSecond.TextSize = 12
- NewSecond.BackgroundTransparency = 1
- NewSecond.Parent = Seconds
- local function ClearAll()
- for _, Object in ipairs(Hours:GetChildren()) do
- if (NewHour) and (not (Object == NewHour)) then
- Object:Destroy();
- end
- end
- for _, Object in ipairs(Minutes:GetChildren()) do
- if (NewMinute) and (not (Object == NewMinute)) then
- Object:Destroy();
- end
- end
- for _, Object in ipairs(Seconds:GetChildren()) do
- if (NewSecond) and (not (Object == NewSecond)) then
- Object:Destroy();
- end
- end
- end
- local function UpdateTime()
- local GameTime = math.floor(workspace.DistributedGameTime+0.5)
- local Hour = math.floor(GameTime/(60^2))%24
- local Minute = math.floor(GameTime/(60^1))%60
- local Second = math.floor(GameTime/(60^0))%60
- if OldHour ~= Hour then
- spawn(function()
- pcall(function()
- local Old = Hours:FindFirstChild("Old")
- TweenService:Create(Old, TweenInfo.new(0.5), {Position = UDim2.fromScale(0,-1)}):Play()
- wait(0.5)
- Old:Destroy()
- end)
- end)
- NewHour = Instance.new("TextLabel")
- NewHour.Name = "Old"
- NewHour.Text = Hour
- NewHour.Size = UDim2.fromScale(1,1)
- NewHour.Font = Enum.Font.Gotham
- NewHour.Position = UDim2.fromScale(0,1)
- NewHour.TextColor3 = Color3.fromRGB(255,255,255)
- NewHour.TextSize = 12
- NewHour.BackgroundTransparency = 1
- NewHour.Parent = Hours
- pcall(function()
- TweenService:Create(NewHour, TweenInfo.new(0.5), {Position = UDim2.fromScale(0,0)}):Play()
- end)
- end
- if OldMinute ~= Minute then
- spawn(function()
- pcall(function()
- local Old = Minutes:FindFirstChild("Old")
- TweenService:Create(Old, TweenInfo.new(0.5), {Position = UDim2.fromScale(0,-1)}):Play()
- wait(0.5)
- Old:Destroy()
- end)
- end)
- NewMinute = Instance.new("TextLabel")
- NewMinute.Name = "Old"
- NewMinute.Text = Minute
- NewMinute.Size = UDim2.fromScale(1,1)
- NewMinute.Font = Enum.Font.Gotham
- NewMinute.Position = UDim2.fromScale(0,1)
- NewMinute.TextColor3 = Color3.fromRGB(255,255,255)
- NewMinute.TextSize = 12
- NewMinute.BackgroundTransparency = 1
- NewMinute.Parent = Minutes
- pcall(function()
- TweenService:Create(NewMinute, TweenInfo.new(0.5), {Position = UDim2.fromScale(0,0)}):Play()
- end)
- end
- if OldSecond ~= Second then
- spawn(function()
- pcall(function()
- local Old = Seconds:FindFirstChild("Old")
- TweenService:Create(Old, TweenInfo.new(0.5), {Position = UDim2.fromScale(0,-1)}):Play()
- wait(0.5)
- Old:Destroy()
- end)
- end)
- NewSecond = Instance.new("TextLabel")
- NewSecond.Name = "Old"
- NewSecond.Text = Second
- NewSecond.Size = UDim2.fromScale(1,1)
- NewSecond.Font = Enum.Font.Gotham
- NewSecond.Position = UDim2.fromScale(0,1)
- NewSecond.TextColor3 = Color3.fromRGB(255,255,255)
- NewSecond.TextSize = 12
- NewSecond.BackgroundTransparency = 1
- NewSecond.Parent = Seconds
- pcall(function()
- local SecondTween = TweenService:Create(NewSecond, TweenInfo.new(0.5), {Position = UDim2.fromScale(0,0)});
- SecondTween.Completed:Connect(ClearAll);
- SecondTween:Play();
- end)
- end
- OldHour, OldMinute, OldSecond = Hour, Minute, Second
- end
- spawn(function()
- while wait() do
- UpdateTime()
- end
- end)
- end
- if Settings.FPS then
- local FPS = Instance.new("Frame")
- FPS.Name = Settings.Center and "2" or "1"
- FPS.BorderSizePixel = 0
- FPS.BackgroundColor3 = Color3.fromRGB(30,30,30)
- FPS.Size = UDim2.fromScale(0,1) + UDim2.fromOffset(60)
- FPS.Parent = Container
- local FPSContainer = Instance.new("Frame")
- FPSContainer.Name = "Container"
- FPSContainer.BackgroundColor3 = Color3.fromRGB(40,40,40)
- FPSContainer.BorderSizePixel = 0
- FPSContainer.Size = UDim2.fromScale(1,1) - UDim2.fromOffset(2,2)
- FPSContainer.Position = UDim2.fromOffset(1,1)
- FPSContainer.Parent = FPS
- local FPSValue = Instance.new("TextLabel")
- FPSValue.Name = "Value"
- FPSValue.BackgroundTransparency = 1
- FPSValue.Font = Enum.Font.Gotham
- FPSValue.TextSize = 12
- FPSValue.Text = "NaN FPS"
- FPSValue.TextColor3 = Color3.fromRGB(255,255,255)
- FPSValue.Size = UDim2.fromScale(1,1)
- FPSValue.Parent = FPSContainer
- local function RoundTo(N, DP)
- return math.floor(N*(10^DP))/(10^DP)
- end
- local CacheSize = Settings.CacheSize or 5
- local FPSCache = table.create(CacheSize, 0)
- local function ShiftFPSCache(ShiftFPS)
- for i = CacheSize, 1, -1 do
- FPSCache[i] = FPSCache[i - 1] or ShiftFPS
- end
- end
- local function GetFPSAverage()
- local Sum = 0
- table.foreach(FPSCache, function(_, CachedFPS)
- Sum += CachedFPS
- end)
- return Sum / CacheSize
- end
- local function UpdateFPS(ClientFPS)
- ShiftFPSCache(ClientFPS)
- local AverageFPS = GetFPSAverage()
- local TextSize = TextService:GetTextSize((RoundTo(AverageFPS, Settings.Decimals) .. " FPS"), FPSValue.TextSize, FPSValue.Font, Vector2.new(0,0)).X
- FPS.Size = UDim2.fromScale(0,1) + UDim2.fromOffset(TextSize+10,0)
- FPSValue.Text = (RoundTo(AverageFPS, Settings.Decimals) .. " FPS")
- AlignContainer()
- end
- spawn(function()
- game:GetService("RunService").RenderStepped:Connect(function(Delta)
- UpdateFPS(1 / Delta);
- end)
- end)
- end
- AlignContainer()
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement