PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience

Giving Tools to Group Members

Giving Tools to Group Members

Jul 03 2018, 11:14 AM PST 5 min

Giving a tool to everyone in a group

Let’s say you want to give out a weapon, but only to players who are in a certain group. First, place the weapon you want to give out in ServerStorage:

ExplorerDrag.png

Now we want to create a script which gives out the weapon. In the Explorer panel, right-click on ServerScriptService and click Insert Basic Object > Script. Make sure to update the script with your group’s ID and weapon name.

-- change this
local groupId = 57
-- change RocketLauncher to the tool's name
local tool = game.ServerStorage.RocketLauncher

function onPlayerSpawned(player)
  if player:IsInGroup(groupId) then
    tool:Clone().Parent = player.Backpack
  end
end

game.Players.PlayerAdded:connect(function(player)
  player.CharacterAdded:connect(function()
    onPlayerSpawned(player)
  end)
end)

Giving a tool to certain ranks

Let’s modify the script to give the rocket launcher based on rank. Go to your group’s admin page and view the “Roles” tab:

GroupRoles.png

Let’s modify the onPlayerSpawned function we wrote earlier so only the two highest ranks will get a rocket launcher:

function onPlayerSpawned(player)
  if player:GetRankInGroup(groupId) >= 254 then
    tool:Clone().Parent = player.Backpack
  end
end

Or if we wanted to give the rocket launcher only to to the group leader, here is how we would do it:

function onPlayerSpawned(player)
  if player:GetRankInGroup(groupId) == 255 then
    tool:Clone().Parent = player.Backpack
  end
end
Tags:
  • group
  • tools
  • community