Hello I was working on server sided hitboxes for my game, for this I decided to work and fix some of roblox’s netcode so I am working on server sided lag compensation for server sided hitboxes
For this I have to store every player’s position every heartbeat on the server, I do this on a table and I have a function which rewinds all players positions and hitboxes to the time it was asked to
For testing purposes im always rewinding every player’s position to see if it was recording all player’s positions, but it only seems to record one player’s position
This was confusing to me because I made the script loop through all players
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local IsDebugModeOn = true
local RPFolder = workspace.RewoundPositions
local RecordedHB = {}
local LagCompensator = {}
function LagCompensator.StartRecording()
RunService.Heartbeat:Connect(function(DeltaTime)
local CurrentTime = tick()
RecordedHB[CurrentTime] = {
["Players"] = {}
}
for Index,Player in pairs(Players:GetPlayers()) do
if Player.Character then
print(Player)
RecordedHB[CurrentTime]["Players"] = {}
RecordedHB[CurrentTime]["Players"][Player.UserId] = {}
print("User Recorded",Player.UserId, Player.Name, CurrentTime, RecordedHB[CurrentTime]["Players"][Player.UserId])
for i,v in pairs(Player.Character:GetChildren()) do
if v:IsA("BasePart") then
RecordedHB[CurrentTime]["Players"][Player.UserId][v.Name] = {
["Size"] = v.Size,
["CFrame"] = v.CFrame,
}
end
end
end
end
for Index1, Value in pairs(RecordedHB[CurrentTime]["Players"]) do
print("Record Check",Index1, CurrentTime)
end
LagCompensator.RewindPositions(CurrentTime)
end)
end
I added a few print functions on the script to diagnose what the problem was and based on the prints heres what I found out
You can see here how it states how it recorded the user’s position then when i get to the part where i check this it shows how only 1 user was recorded??? this is confusing to me as far as I know im using dictionary tables correctly
Anyways if anyone can point out what the issue is It would be appreciated.