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

Team Change script will not work?

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

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

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