Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Argument 1 missing or nil on LeaderBoard?

Heres the code :

local datastore = game:GetService("DataStoreService"):GetOrderedDataStore("Time")

local function UpdLB()
local success, errormessage = pcall(function()
		local data = datastore:GetSortedAsync(false,100)
		local timepage = data:GetCurrentPage()
		for rank,data in ipairs(timepage) do
			local username = game.Players:GetUserIdFromNameAsync(data.Key)
			local name = username
			local timee = data.Value
			local isonlb = false
			for i, v in pairs(workspace.LB.SurfaceGui.Container.ScrollingFrame:GetChildren()) do
				if v.User.Text == name then
					isonlb = true
					break
				end
			end
			if timee and isonlb == false then
				local newlbfrm = game.ReplicatedStorage:WaitForChild("PlaceHolder"):Clone()
				newlbfrm.User.Text = name
				newlbfrm.Time.Text = timee
				newlbfrm.Number.Text = "#"..rank
				newlbfrm.Position = UDim2.new(0,0, newlbfrm.Position.Y.Scale + (.08 * #workspace.LB.SurfaceGui.Container.ScrollingFrame:GetChildren()),0)
				newlbfrm.Parent = workspace.LB.SurfaceGui.Container.ScrollingFrame
				end
		end
	end)
	if not success then
		warn(errormessage)
	end
end	

while wait(10) do
	for _, frame in pairs(workspace.LB.SurfaceGui.Container.ScrollingFrame:GetChildren()) do
		frame:Destroy()
	end
	UpdLB()
	print("updated")
end

It warns me in the output "Argument 1 missing or nil" I scanned it 3 times and nothing.

3 comments

0

do you know which line errored

0

No it just returns "Argument 1 missing or nil" in output and when I click on it, it takes me to like 29.

0

Line*

1 answer

try

local datastore = game:GetService("DataStoreService"):GetOrderedDataStore("Time")

local function UpdLB()
local success, errormessage = pcall(
        local data = datastore:GetSortedAsync(false,100)
        local timepage = data:GetCurrentPage()
        for rank,data in ipairs(timepage) do
            local username = game.Players:GetUserIdFromNameAsync(data.Key)
            local name = username
            local timee = data.Value
            local isonlb = false
            for i, v in pairs(workspace.LB.SurfaceGui.Container.ScrollingFrame:GetChildren()) do
                if v.User.Text == name then
                    isonlb = true
                    break
                end
            end
            if timee and isonlb == false then
                local newlbfrm = game.ReplicatedStorage:WaitForChild("PlaceHolder"):Clone()
                newlbfrm.User.Text = name
                newlbfrm.Time.Text = timee
                newlbfrm.Number.Text = "#"..rank
                newlbfrm.Position = UDim2.new(0,0, newlbfrm.Position.Y.Scale + (.08 * #workspace.LB.SurfaceGui.Container.ScrollingFrame:GetChildren()),0)
                newlbfrm.Parent = workspace.LB.SurfaceGui.Container.ScrollingFrame
                end
        end
    end)
    if not success then
        warn(errormessage)
    end
end 

while wait(10) do
    for _, frame in pairs(workspace.LB.SurfaceGui.Container.ScrollingFrame:GetChildren()) do
        frame:Destroy()
    end
    UpdLB()
    print("updated")
end

3 comments

0

What changed?

0

And it prints nothing.

0

I think im gonna have to rewrite your script is that okay?

This discussion is preserved as it was. New answers, comments, and votes are closed.