Group Rank Team Tool

Hi, So I’m wondering how I would make a Group Rank Team tools, for example:

  • Player goes on Army(Team name) Team.
  • Their rank is 5+(ID) in the group.
  • They get their tool(s).
  • If their not 5+, they do not get their tools.
    Please help me with making this. Thank you!(I can’t find any way to learn this on video tutorials.)
    Note: I’m very new at scripting!

Well, let’s break this down here :thinking:

You’d first want to create the Teams service by finding the “Insert Service” button inside Studio:

image

You can call this nifty function called: Player:GetRankInGroup() which returns back the Rank Number they’re currently in (In addition with a PlayerAdded event)

You could reference the Tools inside a Folder in ServerStorage, use GetChildren() which returns back a table of all the Tools stored in that “Folder”, and again calling GetRankInGroup() would give you the Rank Number so you could check if the Player has a rank that’s higher than 5 or more, clone the tools then parent them to their Backpack/StarterGear

Code example? :thinking: Keeping in mind this is a Script in ServerScriptService:

local GroupID = 0000 --Replace this with your GroupID here
local Tools = game.ServerStorage:WaitForChild("Tools"):GetChildren() --Returns back a table
local ToolRequirement = 5

game.Players.PlayerAdded:Connect(function(Player)
    local PlayerRank = Player:GetRankInGroup(GroupID) --This would return a number

    if PlayerRank >= ToolRequirement then --Check if the PlayerRank is greater or equal than 5
        for _, Tool in pairs(Tools) do
            Tool:Clone().Parent = Player.Backpack
            Tool:Clone().Parent = Player.StarterGear
        end
    end

end)
1 Like

Thanks, Let me try… By the way, in the Insert Service image
Which Service am I supposed to insert(The services I found).

You probably already have the Teams Service set up inside your Explorer then

Ah, I do. Alright. Thanks!!!

Okay, so it does work. But, I want them to be on the “Army” team for them to get the Tool, currently when I run studio I instantly get it without being on the Army Team.

You could just check if the Player’s Team is equal to the Team that you’re searching for, try this:

local Teams = game:GetService("Teams")
local Army = Teams:WaitForChild("Army")

local GroupID = 0000 --Replace this with your GroupID here
local Tools = game.ServerStorage:WaitForChild("Tools"):GetChildren() --Returns back a table
local ToolRequirement = 5

game.Players.PlayerAdded:Connect(function(Player)
    local PlayerRank = Player:GetRankInGroup(GroupID) --This would return a number

    if PlayerRank >= ToolRequirement and Player.Team == Army then --Check if the PlayerRank is greater or equal than 5
        for _, Tool in pairs(Tools) do
            Tool:Clone().Parent = Player.Backpack
            Tool:Clone().Parent = Player.StarterGear
        end
    end

end)

Although, it depends on when you want them to exactly give the tools

I gave a brief PlayerAdded event example

Alright thanks you, I hope this works.

The code provided has the material needed for cloning, however, since you want to clone the items when they switched to the Army Team, you’d need to utilise :GetPropertyChangedSignal(plr.Team). (before his second post)

local groupId = 0000 --your groupId
local army = game:GetService("Teams").Army
local tools = game.ServerStorage:WaitForChild("Tools"):GetChildren() --put all your tools in the "Tools" folder in ServerStorage
local minRank = 5 --which rank id can start using it
game.Players.PlayerAdded:Connect(function(plr) --player connected
    plr:GetPropertyChangedSignal(plr.Team):Connect(function() --listens to when their Team has changed
        if plr.Team == army and plr:GetRankInGroup(groupId) >= minRank then
        --if the player is in Army and is above rank id of 5 then
            for _, tool in pairs(tools) do --for every tool in the folder do
                 Tool:Clone().Parent = Player.Backpack --put in the player's backpack
                 Tool:Clone().Parent = Player.StarterGear --put in the player's startergear
            end
        end
    end)
end)

I’m a little confused… Can you put the entire script?(And if you can explain it that’d be nice)

That’s the entire script - however, it doesn’t provide the function of changing their team, only cloning their items.

Can you please provide the function of their team being changed?

Well, I don’t know when you want it to happen - however,

game.Players.PlayerAdded:Connect(function(plr)
    if plr:GetRankInGroup(groupId) >= minRank then
        plr.Team = army
    end
    --rest of code here
end)

I’ve also updated the code above.

I want it to happen when their team is changed and they reset.

local groupId = 0000 --your groupId
local army = game:GetService("Teams").Army
local tools = game.ServerStorage:WaitForChild("Tools"):GetChildren() --put all your tools in the "Tools" folder in ServerStorage
local minRank = 5 --which rank id can start using it

local function checkIfInArmy(plr)
    if plr.Team == army and plr:GetRankInGroup(groupId) >= minRank then
    --if the player is in Army and is above rank id of 5 then
        for _, tool in pairs(tools) do --for every tool in the folder do
             Tool:Clone().Parent = Player.Backpack --put in the player's backpack
        end
    end
end

game.Players.PlayerAdded:Connect(function(plr) --player connected
    if plr:GetRankInGroup(groupId) >= minRank then
        plr.Team = army
    end
    plr:GetPropertyChangedSignal(plr.Team):Connect(function() --listens to when their Team has changed
        checkIfInArmy(plr)
    end)
    plr.CharacterAdded:Connect(function(char) --each time they respawned
        checkInInArmy(plr)
    end)
end)
1 Like

This is not working
game.Players.PlayerAdded:Connect(function(plr) --player connected
if plr:GetRankInGroup(groupId) >= minRank then
plr.Team = army
“plr.Team = army” it seems that it’s teaming them army, I want them if their on the team and reset it will give them the tool.

Oh right, my bad, I’ve done that hence I thought you wanted to make them Army at the start. Remove that check statement.

So, GetPropertyChangedSignal is an event that would fire a function whenever that specific property of the Instance changes (Let’s say, the Player’s Team)

In addition to what @Doqee stated, you can add this with a CharacterAdded Event as well which would frequently check the Player’s Team whenever it both changes, and when a Character Model gets added to the game (Since we’re calling the CharacterAdded event, we don’t need to reference the Player’s StarterGear)

local Teams = game:GetService("Teams")
local Army = Teams:WaitForChild("Army")

local GroupID = 0000 --Replace this with your GroupID here
local Tools = game.ServerStorage:WaitForChild("Tools"):GetChildren() --Returns back a table
local ToolRequirement = 5

local function CheckTeam(Player)
    local PlayerRank = Player:GetRankInGroup(GroupID) --This would return a number

    if PlayerRank >= ToolRequirement and Player.Team == Army then --Check if the PlayerRank is greater or equal than 5
        for _, Tool in pairs(Tools) do
            Tool:Clone().Parent = Player.Backpack
        end

    end
end

game.Players.PlayerAdded:Connect(function(Player)

    CheckTeam(Player)

    Player.CharacterAdded:Connect(function(Character)
        CheckTeam(Player)
    end)

    Player:GetPropertyChangedSignal("Team"):Connect(function()
        CheckTeam(Player)
    end)
end)

I’m unsure if this would work but try this?

2 Likes

Works, thank you SOOOO Much!(Characters)

1 Like

So its not working for me could you give me an example of what it would look like?