Hi, I wanted you guys to help me fix this script, because it’s got a problem is if I insert any tools into a team and after am test, they will receive 2 tools instead 1 of it, although I was try many ways different but it’s still not working[Note: I dont insert more any script to clone that tools]
--Just put weapons in the team.
function teamFromColor(color)
for _,t in pairs(game:GetService("Teams"):GetChildren()) do
if t.TeamColor==color then return t end
end
return nil
end
function onSpawned(plr)
local tools = teamFromColor(plr.TeamColor):GetChildren()
for _,c in pairs(tools) do
c:Clone().Parent = plr.Backpack
end
end
function onChanged(prop,plr)
if prop=="Character" then
onSpawned(plr)
end
end
function onAdded(plr)
plr.Changed:connect(function(prop)
onChanged(prop,plr)
end)
end
game.Players.PlayerAdded:connect(onAdded)