Please help with this modulescript about pins

local plr = game.Players.LocalPlayer
local PinSettings = {
	--[[
	[player userid] = {
		[pin name] = "rbxassetid://pin image id",
	}
	]]

	----------------------------------test------------------------------------------

	----------------------------------awards------------------------------------------
	
	--------------------------------------------------------------------
	["123"] = {-- 
		["b"] = "rbxassetid://",
	},
		
}

return PinSettings

how do I make in this module script (its about leaderboard pins) that if their rank in the group is number 5 then they get a pin

If rank == 5 then
[""..plr.UserId] = { 
["burger"] = "rbxassetid://123",
},
2 Likes

What’s the issue with what you’re doing right now?

2 Likes

Oh you’re asking what the function is, you can use Player:GetRankInGroup()

2 Likes

no, not the function
when I use if plr is that rank i want it to automatically give him that pin but it red lines the script

2 Likes

Could you show me what is red underlined?

2 Likes

plr:GetRankInGroup(32738823):GetRankInGroup(5)
[""plr.UserId] = {
[“Media”] = “rbxassetid://12284632325”,
},

3 Likes

I assume you want to get the user’s rank, you can do this using Player:GetPlayerInRank, to do this, you should return a function that you can check against the player

return function(player: Player)
  local rank = player:GetRankInGroup(id)
  -- rank here will be a number that is the user rank
  -- for example
  if rank == 5 then
    print("meow")
  end
end

From there, you can call this function from code requiring the module with the player you want to check the rank of

local pinSetter = require(path)
pinSetter(player)
2 Likes

I’m kind of confused on why you’re chaining the GetRankInGroup functions, that will cause an error. And you need to concatenate “” and plr.UserId like “”…plr.UserId otherwise it’ll error - but there isn’t any point in doing that you can just do tostring(plr.UserId).

2 Likes

its a module script with it being inside a local pinsettings = {
like that it wouldnt work and just redline

3 Likes

I dont know what exactly you’re trying to do here, my current guess is that you’re trying to figure out what icon to show based on the user’s rank in a group.

If you want to expand what I sent previously where you can assign an image to a rank, refactor the module to this:

local pins = {
  [5] = "rbxassetid://123456",
  [6] = "rbxassetid://111",
  ...
}

return function(player: Player): string
  local rank = player:GetRankInGroup(id)
  -- rank here will be a number that is the user rank
  -- for example
  return pins[rank]
end
2 Likes

the format would be
[“plrid”] = {
[“pinnameformenu”] = “rbxassetid://”,
}

anything other then that wouldnt work

2 Likes

Just don’t chain the GetRankInGroup functions (Remove the last one) and tostring(plr.UserId).

2 Likes

yeah that would get the plr.userid except i want to make it in that module,
if rank ==5 then
[“”] = {
["} = “rbxassetid://”,
},
if i used anything like if, then, or end it red lines

2 Likes

I saw on your original post you have the if in the if statement is capitalized, make sure it isn’t or else the entire if statement will be underlined red.

2 Likes

that was a accident not the real code i tried, it redlines still

2 Likes

You also need to add an end and remove the comma after the table, if you would say what the error says that would be helpful. It’s kinda hard to understand you.

2 Likes
local plr = game.Players.LocalPlayer
local rank = plr:GetRankInGroup(32738823)
local PinSettings = {

	----------------------------------test------------------------------------------

	----------------------------------awards------------------------------------------
	
	------------------------------machnselection--------------------------------------
	["774222394"] = {-- m_acch
		["GOAT"] = "rbxassetid://13692919933",
		["JOHNPORKISCALLING"] = "rbxassetid://12950742331",
		["PETER"] = "rbxassetid://12284632325",
	},
	["419104033"] = { --   Selection_2
		["GOAT"] = "rbxassetid://13692919933",
		["JOHNPORKISCALLING"] = "rbxassetid://12950742331",
		["PETER"] = "rbxassetid://12284632325",
	},
redlines under	
	if rank == 6 then
	[tostring(plr.UserId)] = {
			["Media"] = "rbxassetid://12284632325",
end
		}, 
		
}
redlines over
return PinSettings
2 Likes

I’m just gonna write it out for you lol

local plr = game.Players.LocalPlayer
local rank = plr:GetRankInGroup(32738823)
local PinSettings = {

	----------------------------------test------------------------------------------

	----------------------------------awards------------------------------------------

	------------------------------machnselection--------------------------------------
	["774222394"] = {-- m_acch
		["GOAT"] = "rbxassetid://13692919933",
		["JOHNPORKISCALLING"] = "rbxassetid://12950742331",
		["PETER"] = "rbxassetid://12284632325",
	},
	["419104033"] = { --   Selection_2
		["GOAT"] = "rbxassetid://13692919933",
		["JOHNPORKISCALLING"] = "rbxassetid://12950742331",
		["PETER"] = "rbxassetid://12284632325",
	},
}

if rank == 6 then
	PinSettings[tostring(plr.UserId)] = {
		["Media"] = "rbxassetid://12284632325",
	}
end

return PinSettings
2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.