✓ Accepted answer
Hello! I am here to help.
The most efficient way (at least that I know of) is to make an if statement INSIDE the if statement,
Example:
local var1 = 1
local var2 = 15
local var3 = 25
if var2 >= 20 or var3 >= 20 then
if var2 >= 20 then
print('var2 is greater than 20!')
else
print('var3 is greater than 20!')
end
end
It checks if either are greater than 20.
If either are, then it checks which one is greater than 20.
So, your "fixed" code:
local hp = script.Parent.MainHealth
local impactVelocity = parent.Velocity.Magnitude
local hitVelocity = hit.Velocity.Magnitude
if impactVelocity >= 20 or hitVelocity >= 20 then
if impactVelocity >= 20 then
hp.Value = hp.Value - impactVelocity
else
hp.Value = hp.Value - hitVelocity
end
end
.
Hope this helped you!
Note: I mean, there really isn't an explanation to this, it's just that you make another if statement inside the if statement.
5 comments
could you elaborate?
why not use 2 separate if statements lmao
greatneil80 Because i only want one dealing damage at a time
exclusive or should help then
Wayyllon I'm trying to make the vehicle take damage when it hits a part and gets hit by a part, impactVelocity is for how fast the car hits something and hitVelocity is how fast the car is hit by something, and hp is the health of the vehicle so when the vehicle hits something or is hit by something fast enough it will take damage but I can't figure out how to find what one is 20 or above.