Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How does TakeDamage work on dummies?

Asked by 2 years ago

I'm trying to make a script where the dummy takes 50 damage every second in a loop but Takedamage doesn't seem to work, does anybody know why?

0
can you show us your script? and also specify if it is a script or local script. NGC4637 602 — 2y

2 answers

Log in to vote
0
Answered by
Xapelize 2658 Moderation Voter Community Moderator
2 years ago

Im guessing TakeDamage function is deprecated. But for a safer method, do this:

Humanoid.Health = Humanoid.Health - 50

Also, I think you can try this way if it did not get deprecated yet:

Humanoid:TakeDamage(50)

The difference of them is the first script damages the character even he have forcefield on, while TakeDamage does not.

0
TakeDamage function is not deprecated imKirda 4491 — 2y
0
oh yes i though it did because i recall some functions being deprecated but not takedamage maybe...... Xapelize 2658 — 2y
Ad
Log in to vote
0
Answered by 2 years ago
Edited 2 years ago

Here is the baseline of TakeDamage() (might not be entirely correct):

function Humanoid:TakeDamage(self, hp)
    self.Health = self.Health - hp
end

TakeDamage() behaves in the exact same manner as health = health - damage. A value damage is subtracted from health, with the lowest possible Health value being 0 under normal circumstances.

The function does not behave differently whatsoever when used on NPCs and Players. Both of their Humanoids will take damage the same way, with no exceptions (if you exclude the Humanoid having 0 Health).

As for your issue, there are a few possibilities as to why the function isn't working:

  • There could be a line of code that the script cannot pass, such as a condition not passing. Make sure all of your conditions pass. The best function to use for this purpose is print().
  • You could be calling the function from an Instance that is not a Humanoid. Ensure that the Instance is a Humanoid and not nil.
  • You could be using a LocalScript. LocalScripts don't run if they don't have a client to attach themselves to. A NPC is not a client, and therefore the script doesn't run. If this is the case, use a regular Script.

Answer this question