This script is used to add an item to a players backpack once they are on a certain team but when ever I test it it always adds 4 items instead of only 1.
local Tools = { ["Assassins"] = game.ServerStorage.Tag, } while true do wait(5) game.Players.PlayerAdded:connect(function(plr) plr.CharacterAdded:connect(function(char) plr.Changed:connect(function() if plr.Team == game.Teams.Assassins then Tools.Assassins:Clone().Parent = plr:WaitForChild("Backpack") end end) end) end) end
Ok so I removed the while loop and I tried to add a check but it still adds 2 items to the players that join the team
local Tools = { ["Assassins"] = game.ServerStorage.Tag, } wait(5) game.Players.PlayerAdded:connect(function(plr) plr.CharacterAdded:connect(function(char) local NumItems = plr.Backpack:GetChildren() plr.Changed:connect(function() if NumItems == 1 then return end if plr.Team == game.Teams.Assassins and #NumItems == 0 then Tools.Assassins:Clone().Parent = plr:WaitForChild("Backpack") print(#NumItems) end end) end) end)