So, basically I managed to make a script that gives members of a group tools, however, if players who are in the group change their team, they still keep their group tools (I'd like to mention that when you change team, you also die). I know I am meant to add some condition that if the player changes their team, then the tools they received as group members are meant to be destroyed, however I am not certain how to do it. I would really appreciate the help.
Here is the script:
groupID = 2827623
tools = game.ServerStorage:GetChildren()
game.Players.PlayerAdded:connect(function(player)
player.CharacterAdded:connect(function(char)
if player:GetRankInGroup(groupID) > 1 then
for i = 1, #tools do
if tools[i].Name == "SomeTool1" then
local c = tools[i]:Clone()
c.Parent = player.Backpack
end
end
elseif player:GetRankInGroup(groupID) == 1 then
for i = 1, #tools do
if tools[i].Name == "SomeTool2" then
local c = tools[i]:Clone()
c.Parent = player.Backpack
end
end
end
end)
end)

1 comment
Thank you!