This is a system that would work in this scenario. For the rundown,
The Player Coordinates device’s properties are set to update the Properties named x and y, this tracks where the player is and allows it to be used in block code.
The Properties named x and y are number values scoping to the player, so each player has an individual coordinate value.
The Properties starting with a, which I named to mean attack, such as aname, ax, and ay are also number values. However, these are not connected to the Player Coordinates device, and they scope globally.
Now for the Game Overlay device’s properties, a channel named “Press,” will transmit on the button click, and there’s a block code when receiving on this channel also within the Game Overlay.
This sets the “a” properties as a reference point for later.
The Game Overlay is wired to and triggers the Relay on button press, you could also opt for the “Press” channel rather than the wire. The Relay audience is “All Players.”
The Relay triggers the Trigger, and you can set its properties so that it cannot be tampered with during the game. The main reason for this Trigger is the block code. When the Trigger is triggered, it runs the, “When Triggered” block
Although it may look complicated, the general idea is that it checks the distance which is the math using √(x-ax)²+(y-ay)² and if it is less than a number, or in other words, if a player is within a certain range from another player and they are not the same player, it broadcasts the “Damage” message.
The Damager damages the player when receiving the “Damage” message, and you can change the Damage amount to whatever suits you.
Overall, this system expends about 4,745 memory, but feel free to make it more efficient or add modifications such as swapping the name system for a value unique to each player as the current name system causes it so players with the same name cannot attack each other. You can use your own property and channel names, of course.