Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why won't this script that gives certain tools to a team work?

here's the script..

function onRespawn(character,player)
teamColor=player.TeamColor
for count,a in pairs(game.Teams:GetChildren()) do
if a.TeamColor=teamColor then
team=a
end
end
if team==nil then return end
weps=game.Lighting.TeamsStarterpack:findFirstChild(team.Name)
if weps==nil then return end
for count,a in pairs(weps:GetChildren()) do
weps:clone().Parent=player.Backpack
end
end
workspace.ChildAdded:connect(function(character) player=game.Players:GetPlayerFromCharacter(character) if player~=nil then onRespawn(character,player) end end)

player:Kill()

end

2 comments

0

Please post the entire script, so we can see what your variables are Also, please tab your code correctly.

0

this is the entire script..

1 answer

✓ Accepted answer

Line 4 is incorrect. You are using an incorrect operator, =, which should be ==. Also, you should practice better indentation, so the code is better to read like so:

function onRespawn(character,player)
teamColor = player.TeamColor
for _, a in pairs(game.Teams:GetChildren()) do
	if a.TeamColor == teamColor then
		teamColor = a
	end
end
if team == nil then return end
weps = game.Lighting.TeamsStarterpack:findFirstChild(team.Name)
if weps == nil then return end
	for _, a in pairs(weps:GetChildren()) do
		weps:clone().Parent = player.Backpack
	end
end
workspace.ChildAdded:connect(function(character) 
	player = game.Players:GetPlayerFromCharacter(character)
    if player ~= nil then onRespawn(character, player) end 
end)
player:Kill()
end

This discussion is preserved as it was. New answers, comments, and votes are closed.