Click Detection Group ID Help

Hey everyone, I’m trying to make a Click Detector that checks if a player is in a group and a correct rank value before, and if true, grants the player the tool in their backpack, but if false, doesn’t grant them the item in their backpack. I have this so far and would love some help.

ClickDetector.MouseClick:Connect(function (player)
    if player:IsInGroup(5038402) >=3 then
        local ReplicatedStorage = game:GetService("ReplicatedStorage")
		local Part = script.Parent
		local ToolName = Part.itemName.Value
		local Tools = ReplicatedStorage.Tools

		local Backpack = Player.Backpack
		local Tool = Tools:FindFirstChild(ToolName)
		Tool:Clone().Parent = Backpack

This code deosnt seem to work.

You must detect the rank of the player.
if Player:GetRankInGroup(GROUPID) >=3 then

1 Like

I put that in place of if player:IsInGroup(5038402) >=3 then but am still experiencing the problem of it not entering my inventory. I am rank 255, and want ranks equal to or greater than 3 to be able to recieve that item in their backpack.

Player:IsInGroup(id) returns a boolean that determines if the player is in the group with the given ID, not an integer that determines their rank. You need to use @OfficialAjoeb’s solution.

1 Like

:IsInGroup only returns a Bool value (True / False) opposed to the rank in the group.

To find the rank you want to use :GetRankInGroup which returns the players rank in the group as a number between 0-255.

If you want to return the rank as a string you can use :GetRoleInGroup - this will return “Guest” if the player is not in the group.

You got two click detectors sir, and they be nested.
What this function will currently do is the following:

  1. Fires when any player clicks on whatever ‘ClickDetector’ is set too.
  2. Checks if they are in group and return a bool value which will never compare true with player:IsInGroup(5038402) >=3 (because bool is never greater than 3)
  3. Make some local variables (which do nothing unless…)
  1. Part.ClickDetector is clicked by any player at all, no matter their placement in the group (as long as a player in the group triggered the first click detector connection).
  2. Clone the tool into that players backpack based off the variables mentioned on line 3.

I assume you’re not expecting two clicks to be involved in the process, so you may want to get rid of the second conection nested in the first one. You should also change player:IsInGroup() to something else like said above.