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)!
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.
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)
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.
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.