I have a script that I want that when the player enters a Team I gave him a Weapon but if the player changes his team I want him to only have the weapon that will be granted when he enters the Team .... What I did in the script is that when the player enters the Team I gave him a Weapon but at the same time I eliminated the player's Backpack, okay I try the script and everything is fine but my problem with that script is that when the player's Backpack is removed the weapon appears that is granted when entering the Team but as Arma [2]. So I went to a Team and they gave me the weapon, then I changed Team and they gave me the other Team's weapon and they eliminated the Weapon I had, okay then it is supposed that the first weapon entered into my 'Backpack' is the one that gives me the first Team I joined; When I enter the other Team, they give me the weapon they give me as a secondary. I hope you understand me Thanks for reading!
It is a Normal Script and it is located in the Workspace .
print("hola")
local teams = game:GetService("Teams")
local Team1 = game.Teams.Police
local Team2 = game.Teams.Criminal
local Tools1 = game.ReplicatedStorage.PoliceTools
local Tools2 = game.ReplicatedStorage.CriminalTools
function Tools()
for _,v in pairs(Tools1:GetChildren())do
v:Clone().Parent = Team1
end
for _,v in pairs(Tools2:GetChildren())do
v:Clone().Parent = Team2
end
end Tools()
local function GetTools1(plr)
for _,v in pairs(Team1:GetChildren())do
local Tools = v:Clone()
Tools.Parent = plr:WaitForChild("Backpack")
for i ,v in pairs(plr:WaitForChild("Backpack"):GetChildren())do
if v ~= Tools then
v:Remove()
end
end
end
end
local function GetTools2(plr)
for _,v in pairs(Team2:GetChildren())do
local Tools = v:Clone()
Tools.Parent = plr:WaitForChild("Backpack")
for i ,v in pairs(plr:WaitForChild("Backpack"):GetChildren())do
if v ~= Tools then
v:Remove()
end
end
end
end
local function JoinedTeam1(player)
print(player.Name, "joined the team 1")
GetTools1(game.Players.LocalPlayer)
end
local function JoinedTeam2(player)
print(player.Name, "joined the team 2")
GetTools2(game.Players.LocalPlayer)
end
Team2.PlayerAdded:Connect(JoinedTeam2)
Team1.PlayerAdded:Connect(JoinedTeam1)

1 comment
that was a very confusing paragraph.