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

How to make a defense system?

Asked by 1 year ago
Edited 1 year ago

For example I want something to only take a certain amount of damage from attacks, like if something does 9000 damage i want it to only do 1 to something with the defense script I don't want it to be like armor, I just want a script that you insert into the humanoid that causes it to not take as much damage from things

Basically like a damage converter

I'm no scripting expert, and in fact i've just recently been getting into it, so a quick and easy answer would be appreciated

0
the damage converts differently for each object? i mean if you get 9000 damage from turret, you get 1 damage with the defense, but what if you get 9000 damage from a gun or anything else, do you always get 1 damage no matter what? imKirda 4491 — 1y
0
Yes. I want it to be 1 damage no matter what damage output the attacker has TerraPico 7 — 1y

1 answer

Log in to vote
0
Answered by 1 year ago

The only way to achieve this is in the damage script itself. So, in whatever script it is you have doing the damage, such as a gun script, you're gonna wanna use an "if statement" to check for a defense tag/value of the target.

For example, if the target has a tag, an object like an int value object renamed "Defense" is a good candidate, then have the damage script check and if it sees the target has that tag, they only take 1. If the damage script doesn't see it, then it does the full 9k.

So, in short, try studying up on if statements and using non-tangible objects like string/int/bool values.

0
There is one issue with this: I have a LOT, and I mean a LOT of things that do damage already, meaning i would have to go through every single one of them and add that. That's why I came here. It would take me months to implement that into every single one of the scripts. TerraPico 7 — 1y
0
Okay I just figured out not everything that does damage attacks it so it won't take as long as i thought. Thank you. TerraPico 7 — 1y
0
Yea. Well, the unfortunate thing when it comes to stuff like that is it does often take a long time. This is why you should often plan your systems and scripts in advance as there is no workaround for issues like this. You'll also likely wanna look into module scripts to make things like this even easier. XxTrueDemonxX 362 — 1y
Ad

Answer this question