-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebugModule.lua
More file actions
48 lines (40 loc) · 1.22 KB
/
Copy pathdebugModule.lua
File metadata and controls
48 lines (40 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
-- Put this in a ModuleScript, and put that in ReplicatedStorage :3 | If you want it to be the same as mine, you can name it "debug".
local playerDebug = {}
playerDebug.__index = playerDebug
function playerDebug.new(player)
local self = setmetatable({}, playerDebug)
self.refreshRate = 4
self.frameCount = 0
self.time = 0
self.fps = 0
self.topSpeed = 0
self.player = player
return self
end
function playerDebug:update(dt)
self.frameCount = self.frameCount + 1
self.time = self.time + dt
if self.time > 1.0 / self.refreshRate then
self.fps = math.floor(self.frameCount / self.time)
self.frameCount = 0
self.time = self.time - 1.0 / self.refreshRate
end
local speed = self.player.Velocity.Magnitude
if speed > self.topSpeed then
self.topSpeed = speed
end
end
function playerDebug:onRenderStepped()
print("FPS: " .. self.fps)
print("Speed: " .. math.floor(self.player.Velocity.Magnitude * 100) / 100 .." (ups)")
print("Top: " .. math.floor(self.topSpeed * 100) / 100 .." (ups)")
end
function playerDebug:stats()
local dict = {
fps = self.fps,
speed = math.floor(self.player.Velocity.Magnitude * 100) / 100 .." (ups)",
top = math.floor(self.topSpeed * 100) / 100 .." (ups)"
}
return dict
end
return playerDebug