Logging time played

Players.PlayerAdded:Connect(function(player)
	timeTrack[player] = tick()
	LoadPlayerData(player)
end)

Players.PlayerRemoving:Connect(function(player)	
	print("Player data exist ["..player.Name.."]")
	local TotalSeconds = tick() - timeTrack[player]
	timeTrack[player] = nil
	local TotalMinutes = (TotalSeconds - TotalSeconds % 60) / 60
	local TotalHours = TotalMinutes/60
	print(TotalMinutes)
	print(TotalHours)
	
	local Leaderstats = player:FindFirstChild("Leaderstats")
	if Leaderstats then
		print("leadestats found")
		local TimePlayed = Leaderstats:FindFirstChild("TimePlayed")
		if TimePlayed then
			print("timeplayed exist")
			TimePlayed.Value = TotalHours
			print(TimePlayed.Value)
			print("doing math")
		end
	end
	CheckPlayerData(player)
end)

is there way that i can get total hour as (0.8) (0.9) (0.3) instead of 0 or 0.033333333 or some random huge numbers? because I want minutes to be calculated too along with hours

i am trying to make it look like to steam hours time played something similar as this
image

print(math.floor(TotalHours * 10) / 10)

how does this work? every 10 mins?

it just shows the first decimal from the totalhours, if it was 10.836194, it would show as 10.8

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.