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

player.TeamColor.Changed:connect(Income) not working correctly?

Ok so my city game runs on teams and this script is spouse to update their income based on their team color but I think the issue is I don't know where TeamColor is stored for the player if someone could answer this for me thanks!

-- By brandonkludke2
player = game:GetService("Players").LocalPlayer


function Income()
	if player.TeamColor == BrickColor.new("Bright blue") then -- local Police Dept.
	player.PlayerGui.MoneyGui.Income.Value = 100
	player.PlayerGui.MoneyGui.Money.Value = 100
elseif player.TeamColor == BrickColor.new("Bright red") then -- local Fire Dept.
	player.PlayerGui.MoneyGui.Income.Value = 75
	player.PlayerGui.MoneyGui.Money.Value = 75
elseif player.TeamColor == BrickColor.new("Dark stone grey") then -- Homeland Security
	player.PlayerGui.MoneyGui.Income.Value = 150
	player.PlayerGui.MoneyGui.Money.Value = 150 
elseif player.TeamColor == BrickColor.new("Bright green") then -- Citizens
	player.PlayerGui.MoneyGui.Income.Value = 50
	player.PlayerGui.MoneyGui.Money.Value = 50
    end --indents!
   end

player.TeamColor.Changed:connect(Income)

1 answer

TeamColor is a property which holds a BrickColor value. BrickColor datatypes have no method Changed. What you want to do is call Changed on the player and check to see if the property that was changed was TeamColor:

player.Changed:connect(function(property)
	if property == "TeamColor" then
		-- Player Changed Teams!
		-- Put Code Here
	end
end)

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