# Different "Cash" Incomes for Different Teams

The Topic: (Isolating the City-RPG part lol)

There are different teams (or “jobs”) that every player can instantly become, and each team has (or will have) its own range of income in Cash.

Every so often, the server will check each of the 65 (at best) players if they’re actually in a “job” (eq. Doctor, Construction, Business). If a player is part of a legitimate job, the system can give a player a random sum of cash - example, math.random(11000,66000) - as well as multiplying it a small amount if the player has a house.

The Actual Issue:

local CashIncome = coroutine.wrap(function()
while true do
wait(10) --debug time, will delay it for 60 - 120 seconds at best

for _,Player in pairs(game.Players:GetPlayers()) do
local CashAmount = math.random(11000,66000)

if Player.TeamColor == BrickColor.new("Institutional white") or BrickColor.new("Black") then --start of the issue
CashAmount = 0
--	return -- edit: never mind, halts the ENTIRE THING
end

if Player.Tags:FindFirstChild("HasHouse") then
CashAmount = CashAmount * (math.random(1125,1300)/1000) --1.125x to 1.3x multiplier, does this cause inflation lol
end

end
end
end)

CashIncome()
What was supposed to happen?
1. Let’s assume Player is part of Cashier, an actual job (We’ll just pretend he doesn’t have a house lol).

2. The system will then check if the player is NOT in a team that is coloured with BrickColor.new("Institutional white") or BrickColor.new("Black").

3. The system is happy and gives the player a random sum, without the house part.

The actual results? (start of the issue)
1. Same PlayerWhoHasJob as Cashier (without a house)
2. The system checks if the player is in a legitimate job.
3. The system thinks the player actually isn’t in a job and doesn’t give the player a random sum.
Followed by later “no-no”(s) from the system to the Player.

What else have I tried?

• Attempted to use the Team itself as a comparing variable to Player.Team
Result: no effect, no sum given
• Attempted to use the Team.Name as a comparing variable to Player.Team
Result: no effect, no sum given
• Last resort: attempted to find other topics related to different IntValue.Value increases to different teams in the span of approx. an hour.
Result: Nowhere near close that?? Be surprised if someone somehow found a similar topic cause I may have rushed it

This statement checks whether or not the player is on the white team; however, it fails to make the same comparison with black. Since a BrickColor is a truthy value (not false or nil), this statement will always be true, and thus no money will be awarded.

if Player.TeamColor == BrickColor.new("Institutional white") or Player.TeamColor == BrickColor.new("Black") then

Edit: Also, I believe the poster above me mentioned this before deleting their post, but you can replace return with the continue keyword to jump out of an iteration in a loop.

2 Likes

It worked! I swear I remembered doing that before, but maybe I screwed it up and went with another way before going back. Other than that, it works in the end with actually fixing up the If statement. Thanks!

(I guess I’ll figure out how to compare with a table myself then…)