I am trying to add the player’s time beating the game to the leaderstats but sometimes it does not count…
finishedRemote.OnServerEvent:Connect(function(player, Time)
local BestTimeStat = player.leaderstats.BestTime
Time = tonumber(Time)
local humanoidTouched = false
wait(1)
local touchingParts = game.Workspace.Level1.Stop:GetTouchingParts()
for _, v in pairs(touchingParts) do
local playercheck = game:GetService("Players"):GetPlayerFromCharacter(v.Parent)
if playercheck then
if playercheck.Name == player.Name then
humanoidTouched = true
end
end
end
if BestTimeStat.Value > Time and BestTimeStat.Value ~= 0 and humanoidTouched == true then
BestTimeStat.Value = Time
print("Set the stats")
elseif BestTimeStat.Value < Time and BestTimeStat.Value ~= 0 and humanoidTouched == true then
print("To slow")
elseif BestTimeStat.Value == 0 and humanoidTouched == true then
BestTimeStat.Value = Time
elseif humanoidTouched ~= true then
end
end)