THIS IS A THING I AM DOING FOR A MOTORSPORT THEMED GAME
I have already authored my own custom timing system which records laps and sector splits. It all works fine aside from the position updating in the Race (I have programmed this to happen 3 times per lap).
The issue is that either the positions break and someone 1 lap down becomes the leader or the order gets messed up so someone 1 lap down becomes P3.
I have tried sorting by their elapsed values (Set when they cross a timing line to os.clock())
I have also tried looping the children of the folder where the order is stored and checking if they are on the same lap and in the same sector
If you need any more details to be able to help me, let me know
function UpdateOrderPositions()
local combined = {}
for i,v in pairs(order:GetChildren()) do
local num1 = v.Laps.Value
local num2 = v.Sector.Value
local final = nil
final = tonumber(num1..""..num2)
table.insert(combined,{v.Name, final})
end
table.sort(combined, function(a,b)
return a[2] > b[2]
end)
for i,v in ipairs(combined) do
print(i)
print(v[2])
game.ReplicatedStorage.SwiftTiming.RaceOrder[v[1]].Position.Value = i
end
end
^ Function which does the position handling