27: attempt to compare number < nil, It doesnt detect Data.Value?

Im making a leaderboard script and this is time urgent so all help is appreciated
Script:

local DSS = game:GetService("DataStoreService")
local TotalSlapsODS = DSS:GetOrderedDataStore("TotalSlaps")
local Algebra = require(script.Parent.ServerScript.Algebra)

--<swag function>--
local function updateboard()
	local success, errorMsg = pcall(function()
		local Data = TotalSlapsODS:GetSortedAsync(false, 5)
		local SlapsPage = Data:GetCurrentPage()
		
		for rank, data in ipairs(SlapsPage) do
			
			local username = game.Players:GetNameFromUserIdAsync(tonumber(data.key))
			local name = username
			local isOnLeaderboard = false
			
			for i, v in pairs(game.Workspace.Leaderboard.MainBoard.SurfaceGui.Frame.ScrollingFrame:GetChildren()) do
				if v:IsA("Frame") then
					if v.PlayersName.Text == name then
						isOnLeaderboard = true
						break
					end
				end
			end
			
			if data.Value > 0 and isOnLeaderboard == false then --Line 27 Error
				
				local newlbframe = script.PlayerTemplate:Clone()
				newlbframe.PlayersName.Text = name
				newlbframe.Score = Algebra:Abbreviate(data.Value)
				newlbframe.PlacementNumber.Text = "#"..rank
				newlbframe.Parent = game.Workspace.Leaderboard.MainBoard.SurfaceGui.Frame.ScrollingFrame
				
				
			end
		end
	end) 	
	if not success then
		print(errorMsg)
	end
end


while true do
	for _, player in pairs(game.Players:GetPlayers()) do
		TotalSlapsODS:SetAsync(player.UserId, player.leaderstats:WaitForChild("TotalSlaps").Value)
	end
	
	for _, frame in pairs(game.Workspace.Leaderboard.MainBoard.SurfaceGui.Frame.ScrollingFrame:GetChildren()) do
		if frame:IsA("Frame") then
			frame:Destroy()
		end
	end
	
	updateboard()
	print("Updated!!")
	
	task.wait(10)
end

If you look on youtube or on the devforum, you will find many topics like this.

Also, are the scrolling frame’s children actual number values?

No they are frames and i used DevKings Tutorial to make this

Try changing data.Value to data.value.

1 Like