Based on what you asked, you may want to use a server script (not LocalScript) for that:
1 | game.Players [ name_of_the_player ] .leaderstats.money.Value = i |
That should be wrapped in a function that connects to an event when the bricks reached the end of the conveyor.
In case if you want it to change in a LocalScript, you can learn how to do the same method using Remote Functions and Events.
Sorry if I'm answering this in a rush. Tell me if you want more info, or wait for others to answer.
EDIT:
Imagine you have some tycoons, each tycoon only has one owner.
This is not the most convenient method to get the player, but it works.
Step 1: Create your own Teams. You can add teams manually in Studio, right to the bottom of the Explorer (the icon of a football). Each teams should have a unique color (and name) of their own.
Step 2: Make sure that only ONE (you can extend the limit if you wish) player can be a part of a team, and cannot change teams after choosing a team or be teammates of other teams that already have a player. The player limit of your game is recommended to be restricted to the number of teams you have. The number of teams of your game will have to be relative to the number of tycoons in the game.
References:
Team class
Player.TeamColor
SpawnLocation (if you plan to use this for the players to change teams, it is useful in some cases)
Step 3: Get the players of the specified team using Team:GetPlayers(). Note that this returns an array of objects represent as members of the team, so you have to index it.
02 | local teams = game.Teams |
03 | local team = teams.NameOfYourTeam |
05 | local plrs = team:GetPlayers() |
08 | table.foreach(plrs, function (key,value) |
09 | if value:IsA( "Player" ) then |
13 | value.leaderstats.money.Value = value.leaderstats.money.Value+ 1 |
table.foreach()
executes a function on each member of the table (array) it got. It's pretty much the same as for i, p in pairs(plrs) do end
.
Step 4: Change the player's leaderboard stats
You can use the method I written above combined with how to assign values to the leaderboard and sum them up into a function. Once done, connect the function to an event that fires every time the blocks reached the end of the conveyor. You can use the .Touched event.
Now, it's time for you to explore with some trial and error on your own! There are plenty of methods to do this.