Leaderboard Script Error

Hi!

So I was recently making a leaderboard script for a friend and I came across a error that I’m unable to locate/fix.

I was wondering if anyone could help? Here’s all the information:

This is what pops up in the output:

This is the script that the error is coming from:

local DataStoreService = game:GetService("DataStoreService")
local StatsLeaderboard = DataStoreService:GetOrderedDataStore("StatsLeaderboard")

local function updateLeaderboard()
	local success, errorMessage = pcall(function()
		local Data = StatsLeaderboard:GetSortedAsync(false, 5)
		local StatsPage  = Data:GetCurrentPage()
		for Rank, data in ipairs(StatsPage) do
			local userName = game.Players:GetNameFromUserIdAsync(tonumber(data.key))
			local Name = userName
			local Stats = data.value
			local isOnLeaderboard = false
			for i, v in pairs(game.Workspace.LeaderboardGP.StatsGUI.Main:GetChildren()) do
				if v.Player.Text == Name then
					isOnLeaderboard = true
					break
				end
			end
			
			if Stats and isOnLeaderboard == false then
				local newLbFrame = game.ReplicatedStorage:WaitForChild("LeaderboardFrame"):Clone()
				newLbFrame.Player.Text = Name
				newLbFrame.Stats.Text = Stats
				newLbFrame.Rank.Text = "#"..Rank
				newLbFrame.Position UDim2.new(0,0, newLbFrame.Position.Y.Scale + (.08 * #game.Workspace.LeaderboardGP.StatsGUI:GetChildren()), 0) -- This is the line the output is refering to.
				newLbFrame.Parent = game.Workspace.LeaderboardGP.StatsGUI.Main
			end
		end
	end)
	
	if not succes then
		print(errorMessage)
	end
end

while true do
	
	for _, player in pairs (game.Players:GetPlayers()) do
		StatsLeaderboard.:SetAsync(player.UserId, player.leaderstats.Stats.Value)
	end
	
	for _, frame in pairs(game.Workspace.LeaderboardGP.StatsGUI.Main:GetChildren()) do
		frame:Destroy()
	end
	
	updateLeaderboard()
	print("Updated")
	
	wait(10)
end

The stats script I’m refering to:

game.Players.PlayerAdded:Connect(function(player)
	
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player
	
	local Stats = Instance.new("IntValue")
	Stats.Name = "StatNameHere"
	Stats.Parent = leaderstats
	
end)

This is the explorer and the names of the items I’m referring to:

Help is greatly appreciated. :slight_smile:

You forgot an = in between the newLbFrame.Position and UDim2.new(0,0, newLbFrame.Position.Y.Scale + (.08 * #game.Workspace.LeaderboardGP.StatsGUI:GetChildren()), 0)

1 Like

Gosh, I’m blind. Thanks for the help and the quick response. :+1:

Just realised I made a lot of typos.