Sword damages only one time

hey it’s me again,so there’s my sword which now does the animation but doesn’t dammages the dummy more than once

so could someone review the script and local script?

no idea why it does that

()


I would recommend subtracting the humanoids health instead

Humanoid.Health - amount

One reason Take Damage might not work is because it only works if a torso is present inside the humanoid you are hitting also it’s a bit wonky

Here is also a resource:

doesn’t do any dammage now,did i do it right?

You would have to do something like:

Humanoid.Health = Humanoid.Health - 50

Your current script would return an error. Also, for the future, the red (sometimes blue) line under the “-“ means that there is something wrong with it. If you hover your mouse it will tell you what the error is.

1 Like


still doesn’t dammage

You aren’t setting CanDamage back to true after you set it to false. Since the script checks if it is true before continuing, you need to make sure it gets set back to true.

1 Like

i’m kind of a newbie with the Scripting so i Don’t really understand what you’re saying

On line 3 of the server script, you set script.Parent.CanDamage.Value to false. However, you never set it back to true in a server script. Instead, you’re setting it in a LocalScript. With how the roblox client-server model works, this change won’t replicate back to the server.

To fix this, you need to put script.Parent.CanDamage.Value = true at some point in the touched event in the server script after waiting a second.

5 Likes

In addition to what realhigbead said,
‘Humanoid.Health’ isn’t defined so your script won’t work.
You would have to use the same ‘reference’ on both sides of the equal side.

p.Parent.Humanoid.Health = p.Parent.Humanoid.Health - 50

3 Likes

you have to set the value t true again

it’s working but the problem is that i’m one shoting every dummy in the server, can you be a bit more precise at where i should put script.Parent.CanDamage.Value = true

Put a wait(1) in-between CanDamage = true and Health = Health - 50 to match the LocalScript’s debounce.

now i hit them once normaly and for the second hit they all get one shot

Could you re-send the script with the changes?

This Could be a simple Debounce issue, try placing print(“Test”) in your touched function and see how many times “Test” is printed

2 Likes

If you mean they are each getting killed in two hits, that is because you are dealing 50 damage twice (which is 100 damage; their whole health bar).

Set the damage based on how many hits you would like each kill to take.

If this is not the issue you are having, do please post your new code and be more specific with what the issue is.

2 Likes