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

Output: "An error occured". Anyone know the problem?

Asked by 10 years ago

Anyone know why this might be bugging out?

oldcolor = BrickColor.new("Toothpaste");
newcolor = BrickColor.new("Toothpaste");
times = 0;

game.Players.PlayerAdded:connect(function(plr)
plr.Changed:connect(function(prop)
print("hi")
if(plr[prop] == plr.TeamColor) then
print("hi1")
times = times+1;
if(times <= 1) then
print("first")
oldcolor = plr[prop];
newcolor = plr[prop];
end
if (times > 1) then
print("notfirst")
newcolor = plr[prop];
if(checkIfOn(oldcolor) == false) then
print("noneonteam")
local team = getTeamWithTeamColor(oldcolor);
team.Parent = game.Lighting;
oldcolor = newcolor;
end
end
end
end)
end)

checkIfOn = function(team)
local plrs = game.Players:GetChildren();
for i=1,#plrs,1 do
if(plrs[i].TeamColor == team) then
return true;
end
end
return false;
end

getTeamWithTeamColor = function(color)
local teams = game.Teams:GetChildren();
for i=1,#teams,1 do
if(teams[i].TeamColor == color) then
return teams[i];
end
end
end

Answer this question