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

Making a money script in which income depends on your team?

So, I've got this script made which gives you 10 Money on the leaderboard every 3 seconds.

print("Money Leaderboard")

function onPlayerEntered(newPlayer)

	local stats = Instance.new("IntValue")
	stats.Name = "leaderstats"

	local mins = Instance.new("IntValue")
	mins.Name = "Money"  --You can put Cash, Gold, Etc.
	mins.Value = 0  --How much you will start on.

	
	mins.Parent = stats
	
	stats.Parent = newPlayer

	while true do
		wait(2)  --Wait time for income.
		mins.Value = mins.Value + 10  --This is how much is given.
	end
end


game.Players.ChildAdded:connect(onPlayerEntered)

How would I make the value depend on your current team?

1 answer

You can do this using an if statement, and the Team property of Player:

print("Money Leaderboard")

function onPlayerEntered(newPlayer)

    local stats = Instance.new("IntValue")
    stats.Name = "leaderstats"

    local mins = Instance.new("IntValue")
    mins.Name = "Money"  --You can put Cash, Gold, Etc.
    mins.Value = 0  --How much you will start on.


    mins.Parent = stats

    stats.Parent = newPlayer

    while true do
        wait(2)  --Wait time for income.
	if newPlayer.Team == game.Teams["NameOfTeam"] then -- Replace NameOfTeam with the name of the team.
                mins.Value = mins.Value + 10  --This is how much is given.
	elseif newPlayer.Team == game.Teams["NameOfOtherTeam"] then
		mins.Value = mins.Value + 15
	end
    end
end


game.Players.ChildAdded:connect(onPlayerEntered)

Note that this script doesn't give any money to people who aren't on a team.

3 comments

0

The script doesn't work. Workspace.Income:20: 'then' expected near 'mins'

0

Sorry; fixed that.

0

The script still doesn't work if I try switching teams.

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