Okay, so I have a script that basically checks the groups of a player, and if the player has a specific rank in a group or higher, he will get tools from a folder cloned in his inventory, that part is working perfectly fine.
Now If I team myself in that team, either via GUI or via Admin Command, I need it to give me the tools.
"
local ToolFolder = script:WaitForChild(“ToolFolder”)
local tools = {“Notepad”,“Torch”,“Traffic Cone”}
local groups = {
{Group = 5559086, Rank = 1}
}
game.Players.PlayerAdded:connect(function(Player)
for i = 1, #groups do – CHECKS GROUPS
if Player:GetRankInGroup(groups[i][“Group”]) >= groups[i][“Rank”] then – VERIFIES PLAYER
for i = 1, #tools do – CHECKS TOOLS
if ToolFolder:FindFirstChild(tools[i]) then
local Cloned = ToolFolder:FindFirstChild(tools[i]):Clone() -- CLONES THE TOOL
Cloned.Parent = game:GetService("StarterPack")-- GIVES IT TO THE PLAYER
wait(1)
local newCloned = game:GetService("StarterPack"):WaitForChild(tools[i]):Clone()
newCloned.Parent = Player.Backpack
end
end
end
end
end)
if ToolFolder ~= nil then
ToolFolder.Parent = game:GetService(“ReplicatedStorage”)
end
"
Now I just added this:
"
local ToolFolder = script:WaitForChild(“ToolFolder”)
local tools = {“Notepad”,“Torch”,“Traffic Cone”}
local groups = {
{Group = 5559086, Rank = 1}
}
if player.Team.Name == “Polizei” then – This is the Team Name which the player needs to be in to get the tools.
game.Players.PlayerAdded:connect(function(Player)
for i = 1, #groups do – CHECKS GROUPS
if Player:GetRankInGroup(groups[i][“Group”]) >= groups[i][“Rank”] then – VERIFIES PLAYER
for i = 1, #tools do – CHECKS TOOLS
if ToolFolder:FindFirstChild(tools[i]) then
local Cloned = ToolFolder:FindFirstChild(tools[i]):Clone() -- CLONES THE TOOL
Cloned.Parent = game:GetService("StarterPack")-- GIVES IT TO THE PLAYER
wait(1)
local newCloned = game:GetService("StarterPack"):WaitForChild(tools[i]):Clone()
newCloned.Parent = Player.Backpack
end
end
end
end
end)
if ToolFolder ~= nil then
ToolFolder.Parent = game:GetService(“ReplicatedStorage”)
end
end
"