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

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

Asked by 8 years ago

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

Log in to vote
0
Answered by
BlackJPI 2658 Snack Break Moderation Voter Community Moderator
8 years ago

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)
Ad

Answer this question