This script isn't mine and the person who made it didn't explain how it worked in their video. It was working for a couple of hours however, all of a sudden it is now coming up with an error. As a result of the error it is no longer working.
To explain what it is supposed to do, when you join each team you are given their specific gear (in my case key-cards). When you re-spawn you still have those key-cards.
This is the script
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)
and this is the error that it is coming up with 16:40:30.121 - TeamColor is not a valid member of Script The error takes me to line 6

2 comments
I am new to scripting so I am not sure how I would do that. Do I just add t:IsA('Team')? If so would I put it in or before the function?
you would put it in the function, you can just put "t:IsA('Team')" in the if statement at line 3 (if t:IsA('Team') and t.TeamColor==color then return t end)