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

Team Change script will not work?

Asked by 9 years ago

Error: 17:44:15.902 - Players.Player.PlayerGui.ScreenGui.Frame.TextButton.Inmates:17: attempt to perform arithmetic on a string value

Script:

player = game.Players.LocalPlayer

function getCountOfPlayersOnTeam(teamBrickColor)
local people = game.Players:GetPlayers()
local a = 0
for i = 1,#people do
if people[i].TeamColor == BrickColor.new(teamBrickColor) then
a = a + 1
end
end
return a
end

team = game.Teams.Police
function onButtonClicked()
    if getCountOfPlayersOnTeam("Deep blue") < 7 then
        player.TeamColor = BrickColor.new("Deep blue")
    else
        script.Parent.Text = "Team Full"
        wait(5)
        script.Parent.Text = "Police"
    end
end

script.Parent.MouseButton1Down:connect(onButtonClicked)

1 answer

Log in to vote
0
Answered by
dyler3 1510 Moderation Voter
9 years ago

Well, you haven't got an answer yet so here: I don't see anything wrong with the script. Try taking the "local" off on line 5. That may be the problem. If it's not, idk what else it would be.

a = 0

I'm not sure what the problem would be besides this. Try it now, and see if it works or not. Hope I helped :P

Ad

Answer this question