[Solved] For Group Only Gear

So I found a script that gives a gear to a certain player, but i want to know if there is a way to make that script give a gear to someone that is in a certain group.

Here is the script I used:

local players = {"Player Name"}
local gear = game.ServerStorage.LinkedSword

game.Players.PlayerAdded:connect(function(plr)
 plr.CharacterAdded:connect(function(chr)
  for i = 1, #players do
   if players[i] == plr.Name then
    gear:Clone().Parent = plr:WaitForChild("Backpack")
   end
  end
 end)
end)
1 Like

You can use the IsInGroup function, that returns true if the player is the groupId you specified as an argument for the function:

local gear = game.ServerStorage.LinkedSword

game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(char)
        if player:IsInGroup(GROUP_ID_HERE) then
            gear:Clone().Parent = player:WaitForChild("Backpack")
        end
    end)
end)
6 Likes