How to make round rewards system?

Hi Developers!

So I want to add a round rewards / round results system, which shows players the total reward or how many kills they aqcuired for the played round.

I think I know how it should be done, but I have no idea if there is a more optimized and simple way of doing it and implement in code.

My theoretical way of doing it

There are values in StarterGUI that will show on the round results in menu

When a new round has started, a timer begins, which will count all the kills and etc., these stats will be transferred to StarterGUI into corresponding values through RemoteEvent

When round has ended, round results UI appears with all rewards, stats for that round and etc. Then, these values are set to 0 when this loop starts over.

I’d be glad to see your advice! And I will really appreciate some script examples too (GUI scripts aren’t necessary)! :hidere:

If you need some more info, please tell me here!

Yeah, you could use tables or intvalues to record kills and use a formula like x50 = reward where x is the amount of kills.

1 Like

Why store the rewards in StarterGUI tho? Can’t you simply create a ModuleScript inside ReplicatedStorage?

1 Like

Also most of the reward calculation should be done on the server, never trust the client blindly. I’m pretty sure you know why.

1 Like

Yeah, the round starting/ending/tracking of stats should be on the server.
The rewards should also be granted to the user from the server but you can use a RemoteEvent the server can send to the client telling them what rewards were granted. A GUI on the client can listen to that “rewardsReceived” remote event and display them.

1 Like

Ye, didn’t think about it in the first place. But I just don’t know how to store these stats for an individual player. I think using the tables idea from @Zer0Wit will be great.

Can you give me some advice how to manage these stats for all players if possible? I’d be very grateful!

There are a few options, it’s very debatable which one is the best, but whatever works for you is fine (different types include tables, values, attributes, etc)

1 Like

Alright then! I’ll try my best, thank you!

Attributes would definitely be a great option here. They are easily resettable and readable so don’t require much integration with your current systems. I think they’re less hassle than instance values and tables would just be a bit of a nightmare as module changes don’t replicate between client and server.

I know @Zer0Wit already said it as a suggestion, but just giving it a vouch for one of the better options. I recently used them for a system of my own just like this.

1 Like

I suggest structuring your round system using a centralized data table for each player, storing key stats such as Kills (round-specific), TotalKills, Wins, and Losses, with persistent values saved to a DataStore. During the round, increment the Kills count whenever a player eliminates an opponent.

At the end of the round, get their total kills to determine what rewards they can obtain. You could implement a probability-based reward system where each eligible item has a weighted chance of being awarded. For instance, if a player reaches 12 kills, they qualify for rewards requiring at least 10 kills, with assigned probabilities (e.g., Item X at 80%, Item Y at 20%).

Of course, you could do it like if a player gets 10 kills or above, they won’t get any items which have requirements below 10 kills.

An example table:

local rewards = {
   ["ITEM A"] = {
    Chance = 60,
    RequiredKills = 5
   },
   ["ITEM B"] = {
    Chance = 30,
    RequiredKills = 10
   }
   ["ITEM C"] = {
    Chance = 7,
    RequiredKills = 18
   }
   ["ITEM A"] = {
    Chance = 3,
    RequiredKills = 25
   }
}

Then you reset the kills back to 0 and do your intermission logic

1 Like

Of course, this is merely a suggestion. If you want simplicity, you can use Attribute based stats like @12345koip suggested.

1 Like

You could use tables with player instances as keys, for example:

local data = {}

game.Players.PlayerAdded:Connect(function(player)
    local initData = {
        Kills = 0,
        Deaths = --get deaths,
        Wins = --get wins,
        Losses = --get losses,
    }

    data[player] = initData
end)

Then to get the data, you can access it by doing local playerData = data[player]

1 Like

Again I’m kinda dumb and stoopid (you can see it by looking at my avatar’s face) so don’t take my suggestions too seriously.

1 Like

Thank you a lot @12345koip and @GodOfPeacefulDeath ! I’ll see what option is going to fit the best and mark a “Solution” on it!

1 Like