R

Fps kount

public
rrixh Jul 20, 2024 Never 31
Clone
Lua fpskounter.notbylulas 45 lines (37 loc) | 1.43 KB
1
-- Constants
2
local UpdateInterval = 1 -- Update interval in seconds
3
4
local gui = Instance.new("ScreenGui")
5
gui.Name = "FPSCounter"
6
gui.Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui")
7
8
local fpsLabel = Instance.new("TextLabel")
9
fpsLabel.Name = "FPSLabel"
10
fpsLabel.Size = UDim2.new(0, 100, 0, 20)
11
fpsLabel.Position = UDim2.new(1, -110, 0, 10)
12
fpsLabel.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
13
fpsLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
14
fpsLabel.TextStrokeColor3 = Color3.fromRGB(0, 0, 0)
15
fpsLabel.TextStrokeTransparency = 0
16
fpsLabel.Font = Enum.Font.SourceSans
17
fpsLabel.TextSize = 18
18
fpsLabel.Text = "FPS: --"
19
fpsLabel.Parent = gui
20
21
-- Variables to track FPS calculation
22
local frameCount = 0
23
local lastUpdateTime = os.clock()
24
25
-- Function to update FPS counter
26
local function updateFPSCounter()
27
frameCount = frameCount + 1
28
local currentTime = os.clock()
29
30
-- Calculate elapsed time since last update
31
local elapsedTime = currentTime - lastUpdateTime
32
33
-- Update FPS every UpdateInterval seconds
34
if elapsedTime >= UpdateInterval then
35
local fps = frameCount / elapsedTime
36
fpsLabel.Text = string.format("FPS: %.2f", fps)
37
38
-- Reset frame count and last update time
39
frameCount = 0
40
lastUpdateTime = currentTime
41
end
42
end
43
44
-- Update FPS counter continuously
45
game:GetService("RunService").RenderStepped:Connect(updateFPSCounter)