# End-game K/D Ratio (đźź§ 4-5/10)

This is a tutorial on how to make a K/D Ratio that will show at the end of the game. For those who donâ€™t know, a K/D Ratio is a statistic in popular shooting games that shows how many times you died versus how many times you knocked out another player.

This system is designed to increase UX (user experience), which will unfortunately create the following disclaimer:

NOTE! This design uses blocks, repeaters, and properties. I will try to explain them as best as I can throughout this guide, but if you have any other questions, please let me know and Iâ€™ll try to help.

# Example

In this scenario, I knocked out a sentry twice and it knocked me out once. This is what the end-game screen looks like:

Note that yes, the system will recognize that a player knocked out a sentry as well, not only players. However, the leaderboard does not account for sentries as knockouts as I have 0 Knockouts on the leaderboard.

# Tutorial

Here is the full system we will be building today:

There will be two parts to this tutorial. Part one will include creating the register system, while Part two will include the end-of-game widget and combination of the two values. Additionally, there is a third part that includes a simplified system that does not have Repeaters or Blocks, which will be much easier for those who are less-experienced with such devices.
If youâ€™re able to build either, pick whichever suits your needs.

Part One - Register System

This is the register system:

The register system will keep track of how many players you have knocked out (kills) and how many times you have been knocked out (deaths).

Step 1: We will begin by placing a Lifecycle device. Set the Event to listen for when â€śPlayer Knocks Outâ€ť.

Step 2: Add a Counter device with a default value of 0. Set â€śYesâ€ť to Update Property and the Property to Update as â€śKillsâ€ť. Important: Set the Count Scope to â€śplayerâ€ť so that the Counter updates per player and not all players.

Step 3: Connect a wire between the Lifecycle device and the Counter so when â€śEvent Occursâ€ť â†’ â€śIncrement counterâ€ť.

Step 4: Place a Property device and set the Name to â€śKillsâ€ť. Make sure the Type is a Number with a default of 0 and that it again updates per player in the Property Scope.

Step 5: This is one register complete. Select all three devices and copy them to a different location with the following changes made:

• Reconnect the wire between the Lifecycle device and the Counter when â€śEvent Occursâ€ť â†’ â€śIncrement Counterâ€ť.
• Change the Lifecycle deviceâ€™s Event to â€śPlayer Knocked Outâ€ť.
• Change the Property Name in both the Counter and the Property devices to â€śDeathsâ€ť.

No other changes should need to be made with the copied system. To test if the system works, temporarily show the Counters when the game starts. Place a Sentry and a Starting Inventory that gives you a weapon. What should happen is that when you knock out the Sentry then the first systemâ€™s Counter should go up, and when you are knocked out by the Sentry the second systemâ€™s Counter should increase. If something doesnâ€™t work, make sure your property names are spelled correctly and that all other parts of the system are correct.

End Part 1

Part Two - Combination System

This is the combination system:

The combination system will take both the K and D values and regularly combine them into, literally, â€śK/Dâ€ť, which will then be displayed at the end of the game.

Step 1: Begin by placing another Lifecycle device, setting its event to listen for â€śGame Startâ€ť.

Step 2: Place a Repeater with a Task Interval of 1.0 seconds and a Stop Strategy to â€śAfter receiving on a channelâ€ť.

Step 3: Connect a wire from the Lifecycle device to the Repeater so when â€śEvent Occursâ€ť â†’ â€śStart repeaterâ€ť.

Step 4: Place a Trigger. Set Visible In-Game and Trigger by Player Collision to No. Go into the Blocks section and create a new â€śWhen triggeredâ€¦â€ť block with the following code:

Step 5: Connect a wire from the Repeater to the Trigger so when â€śRepeater Runs Taskâ€ť â†’ â€śTriggerâ€ť.

Step 6: Place another Property device and set its Name to â€śKD Ratioâ€ť. Important: Make sure the Property Type is set to Text, not number. Leave the default value blank but ensure the Property Scope is per player once again.

Step 7: Place an End of Game Widget device reading the Property â€śKD Ratioâ€ť. Feel free to update the other settings as you please. Hereâ€™s an example of what it could look like:

End Part 2

Part Three - Simplified System

This simplified system will display both K and D similar to Part 2, except in two separate bubbles instead of one.
To make the simplified system, first, create the system from Part 1.

When that is complete, continue with the following:

Step 2: Place two End of Game Widgets. Set one to read the Property â€śKillsâ€ť and the other â€śDeathsâ€ť. Feel free to update the other settings as you please.

End Part 3

I hope that this tutorial helps with your endeavors in GKC. Good luck and have fun building!

11 Likes

Nice guide!

1 Like

Additional note: From my understanding, a regular KD that is not a fraction but instead a decimal like most FPS games is not possible with the limitations of Property devices. I am looking for a solution but for the time being a combined fraction will have to do.

2 Likes

You can do decimals. Just set it inside of the block. Great guide though!

I see, thanks. Iâ€™ll do some more testing. Glad you liked it!

1 Like

I donâ€™t think that you need the loop. I think you can just calculate it when the channel that ends the game is broadcast, or when one of the properties is changed, if the first method doesnâ€™t work.

Could you make it visible when you play the game?

Yes. Make the k/d property broadcast to an overlay block. The block should set the text to the k/d property.

1 Like

Nice guide overall!

You can get k/d decimals by simply dividing kills by deaths (very simple)

Right, but does having a decimal sent to a property force-round it to an integer?

This is kind of off topic, but how do you make that so when you click on text, it opens more of text like how you did?

Can you elaborate further on that?

Do you mean clicking on a Text device it opens a modal on screen?

Can you set the k/d ratio decimal to a property, and then set the leaderboard to it?

It rounds repeating decimals at the thousandth place unless the result is over the digit limit and should keep decimals unless the decimal number is above 17 digits.

No like on this post, where you have to press on â€śpart oneâ€ť and it opens the text after pressing on it.

Ohh yeah ok
When writing a draft click on the settings gear and select Hide Details

To type it manually, write the following:

`[details="Title"]`
`The text to hide`
`[/details]`

Hope this helps

Thanks man, this gonna help alot.

1 Like

Community difficulty rating

• 0/10
• 1/10
• 2/10
• 3/10
• 4/10
• 5/10
• 6/10
• 7/10
• 8/10
• 9/10
• 10/10
• 11/10
0 voters