Best way to detect who's damaged a boss?

I’d like to have a good way of detecting who’s hit a boss so that they can be rewarded when it dies.
The thing is, there’s a bunch of powers/things that can hit the boss, and I don’t want to have it insert a value into the boss for each attack - that’d be a pain.
I honestly don’t have a clue as to what would be the most efficient way to detect such things.

Please let me know some good methods I could use to do this, thanks!


I cannot give you an answer; I don’t know how your damage system works. Please elaborate

There’s multiple powers/attacks that are able to damage npcs and players. They use the Humanoid:TakeDamage() function when taking away health.

What is executing the script? Sword? Gun? Just a looping script?

It’s key codes. SO like the q key, e key, etc.

You can try this way, although not the most efficient way, you can build on it:

When a player damages the NPC, store the player in a table, then once it dies, retrieve it from the table and you can see which players did damage.

The thing is, what would I do to detect who damages the npc?

I’m not to experienced with damage system’s but I would recommend using remote events with the player name as a variable. :FireServer() from when the keycode is pressed.

Well yes, the attacks work like that and all, but what I’m trying to do is have the boss script detect who damages it.

Add another variable to the RemoteEvent with the players name.

This would require some framework:

  1. There will be a module somewhere in a script service that manages the NPCs and player damage
  2. The module will also create a new table to each NPC
  3. The player will require the module when they do damage
  4. The module will deal damage to the NPC and insert the player into that NPCs table
  5. When the NPC dies, retrieve the corresponding table

This might seem hard to do, and yes, it is if you just started using frameworks, but, once you get the hang of it, this is probably one of the most efficient ways to do these kinds of tasks.

1 Like

I’d have to put each power’s event inside of that one script and there’s like 50 of em.

Trying to do this without editing the power scripts as much as possible.

A simple way to do this that I have used:

Make a folder inside the boss. Then check when the player does damage to the boss. Get that player name and store it in a boolvalue. Put this inside the folder and maybe call it “PlayersWhoDamagedBoss”. After that, loop through the values in the folder, and give the rewards to the players.

I don’t know what you mean as I don’t know how your system works. All I can say is use a RemoteEvent. You can just set up another one to make it more simple if needed.

I’m trying to do it without having to put values inside of the boss when the player attacks, as I’d have to do that for each attack - and there’s quite a lot of attacks.

Don’t do it for each attack. Just check when the player has damaged the boss, and then check if they are in the folder or not. If they are not, then add them. It will have a table of all the players who damaged the boss.

Still, I’d have to put something in each attack to detect when the player has damaged a boss.

add a string value to the player upon playeradded. Then each time something damages the player have it also edit the string value with the name of the attacker

i.e. Last = nil
player takes 10 dmg from Nogalo
Last = Nogalo

Again, that would require having to add something to each attack/power.