✓ Accepted answer
Essentially, what the script does is it gets the service of teams and all the children inside it. Then it checks to see if the teamcolor is equal to the color it wants (in other words, it checks the teamcolor with an if statement) and then returns the value (teams).
After that, the second function returns the first function in line 9. What I mean by this is that in line 9, where it says:
local tools = teamFromColor(player.TeamColor):GetChildren()
teamFromColor is the same function as in line 1. (or another word would be return)
Next, the 2 function gets all the people and clones all the tools, and places them in the character's backpack. The third function has an argument of character and player. The character argument checks to see if it's actually a character and then returns the items in the player's backpack.
And lastly, the last function functions when a player enters the game, because there is a PlayerAddedevent:
game.Players.PlayerAdded:Connect(function(player)
end)
Re - edited
function teamFromColor(color)
for _,teams in pairs(game:GetService("Teams"):GetChildren()) do
if teams.TeamColor == color then return teams end
end
return nil
end
function Spawned(player)
local tools = teamFromColor(player.TeamColor):GetChildren()
for _,tools in pairs(tools) do
tools:Clone().Parent = player.Backpack
end
end
function Adjusted(character,player)
if character == "Character" then
Spawned(player)
end
end
function Joined(player)
player.Changed:Connect(function(character)
Adjusted(character, player)
end)
end
game.Players.PlayerAdded:Connect(Joined)
This is pretty hard to explain, if you need me to break it down more, then ask.
3 comments
btw where did you find this script? can you post the link here
https://www.youtube.com/watch?v=KY3s7C0_AlI
Also, I'd recommend using a different script, or an easier alternative (i.e. you could search for a different video). This script is pretty hard to understand for beginners, so I wouldn't recommend it! I recommend people like TheDevKing and Peaspod (Peasfactory) etc