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
Part.ClickDetector.MouseClick:Connect(function(Player)
local Backpack = Player.Backpack
local Tool = Tools:FindFirstChild(ToolName)
Tool:Clone().Parent = Backpack
end)
end
end)
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.
You got two click detectors sir, and they be nested.
What this function will currently do is the following:
Fires when any player clicks on whatever ‘ClickDetector’ is set too.
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)
Make some local variables (which do nothing unless…)
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).
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.