Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --!strict
- local Players = game:GetService("Players")
- local RS = game:GetService("RunService")
- local UIS = game:GetService("UserInputService")
- local GuiService = game:GetService("GuiService")
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- local OS_OVERRIDE_ATTR = "FlexOSOverride"
- local LP = Players.LocalPlayer
- local RE: RemoteEvent = ReplicatedStorage:WaitForChild("FlexStats") :: RemoteEvent
- local function detectDeviceAndOS(): (string,string)
- local override = LP:GetAttribute(OS_OVERRIDE_ATTR)
- if typeof(override) == "string" and #override > 0 then
- local isConsole = GuiService:IsTenFootInterface()
- local device = isConsole and "Console" or ((UIS.TouchEnabled and not UIS.KeyboardEnabled) and "Mobile" or "PC")
- if UIS.GamepadEnabled then device ..= "+Gamepad" end
- return device, override
- end
- local isConsole = GuiService:IsTenFootInterface()
- local device = isConsole and "Console" or ((UIS.TouchEnabled and not UIS.KeyboardEnabled) and "Mobile" or "PC")
- if UIS.GamepadEnabled then device ..= "+Gamepad" end
- local v = version()
- local osName = "Unknown"
- if isConsole then
- osName = "Console"
- elseif UIS.TouchEnabled and not UIS.KeyboardEnabled then
- if string.find(v, "Android") then
- osName = "Android"
- elseif string.find(v, "iOS") or string.find(v, "iPhone") or string.find(v, "iPad") then
- osName = "iOS"
- end
- else
- if string.find(v, "Windows") then
- osName = "Windows"
- elseif string.find(v, "Linux") or string.find(v, "Ubuntu") then
- osName = "Linux"
- elseif string.find(v, "Mac") or string.find(v, "OSX") then
- osName = "macOS"
- end
- end
- return device, osName
- end
- local DEVICE, OSSTR = detectDeviceAndOS()
- print("Detected:", DEVICE, OSSTR)
- local function getResolution(): string
- local cam = workspace.CurrentCamera
- if cam then
- local v = cam.ViewportSize
- return string.format("%dx%d", v.X, v.Y)
- end
- return "0x0"
- end
- local fps, smooth = 60, 0.15
- RS.Heartbeat:Connect(function(dt)
- local inst = 1/math.max(dt, 1/240)
- fps = fps + (inst - fps)*smooth
- end)
- local function fpsColor(f:number): Color3
- if f>=180 then return Color3.fromRGB(120,255,120)
- elseif f>=60 then return Color3.fromRGB(170,255,120)
- elseif f>=45 then return Color3.fromRGB(255,255,120)
- elseif f>=25 then return Color3.fromRGB(255,200,120)
- else return Color3.fromRGB(255,120,120) end
- end
- local function makeBillboard(): BillboardGui
- local bb = Instance.new("BillboardGui")
- bb.Size = UDim2.fromOffset(200, 42)
- bb.AlwaysOnTop = true
- bb.LightInfluence = 0
- bb.MaxDistance = 250
- local tl = Instance.new("TextLabel")
- tl.Name = "FlexLabel"
- tl.BackgroundTransparency = 1
- tl.Size = UDim2.fromScale(1,1)
- tl.Font = Enum.Font.GothamBold
- tl.TextScaled = true
- tl.TextStrokeTransparency = 0.3
- tl.TextStrokeColor3 = Color3.new()
- tl.TextColor3 = Color3.new(1,1,1)
- tl.Text = "..."
- tl.Parent = bb
- return bb
- end
- local function addDonatorTag(bb: BillboardGui)
- if bb:FindFirstChild("DonatorLabel") then return end
- local dl = Instance.new("TextLabel")
- dl.Name = "DonatorLabel"
- dl.BackgroundTransparency = 1
- dl.Size = UDim2.new(1,0,0.5,0)
- dl.Position = UDim2.new(0,0,-0.6,0)
- dl.Font = Enum.Font.GothamBold
- dl.TextScaled = true
- dl.Text = "DONATOR"
- dl.TextStrokeTransparency = 0.2
- dl.TextStrokeColor3 = Color3.new(0,0,0)
- dl.Parent = bb
- local grad = Instance.new("UIGradient")
- grad.Color = ColorSequence.new({
- ColorSequenceKeypoint.new(0, Color3.fromRGB(255,220,100)),
- ColorSequenceKeypoint.new(1, Color3.fromRGB(100,255,120)),
- })
- grad.Rotation = 0
- grad.Parent = dl
- task.spawn(function()
- while dl.Parent do
- for i = 0, 360, 2 do
- grad.Rotation = i
- task.wait(0.05)
- end
- end
- end)
- end
- local function ensureBillboard(char: Model): TextLabel?
- local head = char:FindFirstChild("Head") or char:FindFirstChildWhichIsA("BasePart")
- if not head then return nil end
- local bb = char:FindFirstChild("_FlexBillboard")
- if not (bb and bb:IsA("BillboardGui")) then
- bb = makeBillboard()
- bb.Name = "_FlexBillboard"
- bb.Parent = char
- end
- (bb :: BillboardGui).Adornee = head;
- (bb :: BillboardGui).StudsOffsetWorldSpace = Vector3.new(0,3.2,0)
- return (bb :: BillboardGui):FindFirstChild("FlexLabel") :: TextLabel
- end
- local function renderPlayer(plr: Player)
- if not plr.Character then return end
- local label = ensureBillboard(plr.Character)
- if not label then return end
- local f = tonumber(plr:GetAttribute("FlexFPS") or "n/A")
- local d = tostring(plr:GetAttribute("FlexDev") or "…")
- local o = tostring(plr:GetAttribute("FlexOS") or "…")
- local r = tostring(plr:GetAttribute("FlexRes") or "…")
- label.Text = string.format("%s | %d FPS | %s / %s | %s", plr.DisplayName, math.floor(f+0.5), d, o, r)
- label.TextColor3 = fpsColor(f)
- if plr:GetAttribute("IsDonator") then
- addDonatorTag(label.Parent :: BillboardGui)
- end
- end
- local function wirePlayer(plr: Player)
- plr:GetAttributeChangedSignal("FlexFPS"):Connect(function() renderPlayer(plr) end)
- plr:GetAttributeChangedSignal("FlexDev"):Connect(function() renderPlayer(plr) end)
- plr:GetAttributeChangedSignal("FlexOS"):Connect(function() renderPlayer(plr) end)
- plr:GetAttributeChangedSignal("FlexRes"):Connect(function() renderPlayer(plr) end)
- plr:GetAttributeChangedSignal(OS_OVERRIDE_ATTR):Connect(function() renderPlayer(plr) end)
- local function onChar(char: Model) renderPlayer(plr) end
- if plr.Character then onChar(plr.Character) end
- plr.CharacterAdded:Connect(onChar)
- end
- for _,p in ipairs(Players:GetPlayers()) do wirePlayer(p) end
- Players.PlayerAdded:Connect(wirePlayer)
- LP.Chatted:Connect(function(msg)
- if msg:lower() == "!linux" then
- LP:SetAttribute(OS_OVERRIDE_ATTR, "Linux")
- elseif msg:lower() == "!windows" then
- LP:SetAttribute(OS_OVERRIDE_ATTR, "Windows")
- end
- end)
- task.spawn(function()
- while true do
- local device, osStr = detectDeviceAndOS()
- RE:FireServer({
- fps = fps,
- device = device,
- os = osStr,
- res = getResolution(),
- })
- task.wait(0.25)
- end
- end)
- task.spawn(function()
- while true do
- for _,p in ipairs(Players:GetPlayers()) do renderPlayer(p) end
- task.wait(1.0)
- end
- end)
- local TextChatService = game:GetService("TextChatService")
- TextChatService.OnIncomingMessage = function(message: TextChatMessage)
- local props = Instance.new("TextChatMessageProperties")
- local plr = Players:FindFirstChild(message.TextSource and message.TextSource.Name or "")
- if plr and plr:GetAttribute("IsDonator") then
- local t = os.clock() % 2
- local c1 = Color3.fromRGB(255,220,100)
- local c2 = Color3.fromRGB(100,255,120)
- local lerped = c1:Lerp(c2, t)
- props.PrefixTextColor3 = lerped
- props.TextColor3 = lerped
- end
- return props
- end
Advertisement
Add Comment
Please, Sign In to add comment