Not Understandable Error

Can someone explain why the error is occurring in my script?

local players = game:GetService("Players")
local keyValue = game:GetService("DataStoreService"):GetDataStore("Data")
local marketPlace = game:GetService("MarketplaceService")
local getShirt = function(playerGirl)
	local InventoryUrl = ""
	local HttpService = game:GetService("HttpService")
	local pageNumber = 0
	local Inventory = 0
	local updateInventory = function()
		Inventory = HttpService:JSONDecode(HttpService:GetAsync(string.format(InventoryUrl, pageNumber, playerGirl.UserId))).Data
	local idsOfStuff = {}
	local checkInv = function()
		pageNumber += 1
		local alreadyClaimed = false
		for index, item in next, Inventory.Items do
			if tonumber(item.Creator.Id) == 11352987 then
				for _, w in next, idsOfStuff do
					if w == item.Item.AbsoluteUrl then
						alreadyClaimed = true
				if alreadyClaimed == false then
					table.insert(idsOfStuff, item.Item.AbsoluteUrl)
				if alreadyClaimed == true then
					alreadyClaimed = false
	for i=1, 10 do
	return table.getn(idsOfStuff)

local getRank = function(shirtsBought, playerGuy)
	if shirtsBought == 0 then
		return "Supporter"
	elseif shirtsBought >= 3 then
		if shirtsBought >=5 then
			if shirtsBought >= 8 then
				if shirtsBought >= 11 then
					if shirtsBought >= 15 then
						if shirtsBought >= 20 then
							if shirtsBought >= 25 then
								if shirtsBought >= 30 then
									if shirtsBought >= 40 then
										local groupInfo = game:GetService("GroupService"):GetGroupInfoAsync(11352987)
										if playerGuy:GetRankInGroup(11352987) ~= (240 or 241) then
											return "CUSTOM RANK"
										return groupInfo[playerGuy:GetRankInGroup(11352987)]
									return "Insane Buyer"
								return "Nike Obsession"
							return "Demonic"
						return "Legend"
					return "Elite"
				return "Superstar"
			return "Pro"
		return "Rookie"
π™±πšžπš’ 𝟹+ πš‚πš‘πš’πš›πšπšœ = πšπš˜πš˜πš”πš’πšŽ
π™±πšžπš’ 𝟻+ πš‚πš‘πš’πš›πšπšœ = π™Ώπš›πš˜
π™±πšžπš’ 𝟾+ πš‚πš‘πš’πš›πšπšœ = πš‚πšžπš™πšŽπš›πšœπšπšŠπš›
π™±πšžπš’ 𝟷𝟷+ πš‚πš‘πš’πš›πšπšœ = π™΄πš•πš’πšπšŽ
π™±πšžπš’ 𝟷𝟻+ πš‚πš‘πš’πš›πšπšœ = π™»πšŽπšπšŽπš—πš
π™±πšžπš’ 𝟸𝟢+ πš‚πš‘πš’πš›πšπšœ = π™³πšŽπš–πš˜πš—πš’πšŒ
π™±πšžπš’ 𝟸𝟻+ πš‚πš‘πš’πš›πšπšœ = Nike Obsession
π™±πšžπš’ 𝟹𝟢+ πš‚πš‘πš’πš›πšπšœ = π™Έπš—πšœπšŠπš—πšŽ π™±πšžπš’πšŽπš›
π™±πšžπš’ 𝟺𝟢+ πš‚πš‘πš’πš›πšπšœ = π™ΏπšŽπš›πšœπš˜πš—πšŠπš• πšπš˜πš•πšŽ
local doneLoading = true
	repeat wait(1) until doneLoading == true
	doneLoading = true
	local leaderstats ="Folder")
	leaderstats.Parent = player
	leaderstats.Name = "leaderstats"
	local shirts ="IntValue")
	shirts.Name = "Purchased"
	shirts.Parent = leaderstats
	shirts.Value = getShirt(player)
	local ranking ="StringValue")
	ranking.Name = "Rank"
	ranking.Parent = leaderstats
	print(getRank(shirts.Value, player))
	ranking.Value = getRank(shirts.Value, player) -- LINE 101 ERROR LINE!!
	doneLoading = false


  19:36:49.266  ServerScriptService.Script:101: invalid argument #3 (string expected, got nil)  -  Server - Script:101

I created the function above myself, so how can it create such an error?

What is line 101? Also unrelated, but you can format the getRank function way better by doing something like this:

local function GetRank(shirtsBought, playerGuy)
    if shirtsBought == 0 then return "Supporter" end
    if shirtsBought >= 30 then return "Insane Buyer" end
    if shirtsBought >= 25 then return "Nike Obsession" end
    -- You get the idea
1 Like

Its the line where i used the GetRank() function

Where is line 101? Or else I can’t know the problem.Just type out line 101

I commented above, the getrank

Is it the line local getRank = function(shirtsBought, playerGuy)? Or is it a line inside the function? If it is a line inside the function, please tell me the line.

No, i edited it to let you see line 101

I’m not sure what you’re doing, but it worked perfectly fine on my end after commenting out the getShirt function. This was because it had an http request.

personally was thinking of something like this

if shirtsBought >= 40 then
	-- yadda yadda
elseif shirtsBought >= 30 then
	return "Insane Buyer"
elseif shirtsBought >= 25 then
	return "Nike Obsession"
-- etc etc etc

but i think it overall comes down to preference when it comes to that.
anyway, the actual issue i THINK is… well, i’ve never seen scripts do this, but when you define a function, i don’t think you’re to do this:

local getRank = function(shirtsBought, playerGuy)

but rather:

local function getRank(shirtsBought, playerGuy)

this MIGHT be where the issue is coming from

Okay, but I’m pretty sure both do the same thing.

try it first at least? specifically, the way the function was written. because, i’m not sure if it works like this or not since i’ve never written functions like that before, but it looks like it’s trying to call a value rather than a function when you type getRank(). though, i could also be 100% wrong.

also, noticed that if shirtsbought >= 40, then it returns groupInfo[playerGuy:GetRankInGroup(11352987)]. does this return as a string?

Can you just copy and paste line 101 for me? Is it the line

local getRank = function(shirtsBought, playerGuy)

Is it that line?

No, its the line where i use the function getRank(), not set it.

Can you tell me which line in the function getRank? There are too much lines in the function getRank()

No i mean, at the bottom of the script, i USE the function getRank() and thats the only occurrence that I USE THE FUNCTIOn, not create it.

The line is NOT in the function. the line is where i USE the function.

tell me if that is still unclear :smiley:

Let me tell you. There is an error IN the function. When you CALL the function, the error will also be there. So play the game and call the getRank() function. You will get TWO errors. screen shot the FIRST one to me :slight_smile: Sorry I’m trying to be clear, no offense :slight_smile:

But the error is stating that there is a missing paremeter, not something wrong in the function…