Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 9 years ago

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
0
Please post the entire script, so we can see what your variables are Also, please tab your code correctly. Perci1 4988 — 9y
0
this is the entire script.. zachhg03 35 — 9y

1 answer

Log in to vote
0
Answered by
war8989 35
9 years ago

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
Ad

Answer this question