I have an alltime scoreboard, but i wanna create another version of it where its a daily one instead. I have set up the dateTables but i dont know what to do from there, any help please?

Script:

local dataStoreService = game:GetService("DataStoreService")

local dataStore = dataStoreService:GetOrderedDataStore("Scoreboard")

local board = workspace.Scoreboard

function updateBoard()
	local sucess, err = pcall(function()
		local Data = dataStore:GetSortedAsync(false, 10)
		
		local MailPages = Data:GetCurrentPage()
		
		for Rank, data in ipairs(MailPages) do
			local userName = game.Players:GetNameFromUserIdAsync(data.key)
			
			local name = userName
			
			local mail = data.value
			
			local isBoarded = false
			
			local templated
			
			for i, v in pairs(board.Holder.Holder:GetChildren()) do
				if v:IsA("Frame") then
					if string.split(v.Summed.Text, " ")[2] == name then
						isBoarded = true
						
						templated = v
						
						break
					end
				end
			end
			
			if mail and not isBoarded then
				local clone = board.Template:Clone()
				
				clone.Summed.Text = tostring(Rank) .. ".   " .. name .. " : " .. tostring(mail) .. " Mail"
				
				clone.Parent = board.Holder.Holder
			else
				--[[if mail then
						templated.Named.Text = tostring(Rank) .. ".   " .. name .. " : "
							
						templated.Deliveries.Text = tostring(mail) .. " Mail"
						
						clone.Parent = board.Holder.Holder
					end
				]]--
			end
		end
	end)
	
	if err then
		print(err)
	end
end




local dateTable = os.date("*t", os.time())
local key = "Y:"..dateTable["year"].." M:"..dateTable["month"].." D:"..dateTable["day"]

local day = dateTable["day"]









while true do
	for i, v in pairs(game.Players:GetPlayers()) do
		dataStore:SetAsync(v.UserId, v.DeliveriesMade.Value)
	end
	
	for i, v in pairs(board.Holder.Holder:GetChildren()) do
		if v:IsA("Frame") then
			v:Destroy()
		end
	end
	
	updateBoard()
	
	updateBoardDaily()
	
	print("updated")
	
	wait(5)
end

1 comment

0

I wanna awnser this but idk really, all I think you need is a new value to track daily scores and a way to have that reset. I.E keeping track of days using tick() and adding the number of the day on the end of the datastore name