system
1
Hey,
I’m currently working on a space shooter and I’m starting to add power-ups to it. I had a power-up that gave you an extra life but then i switched from lives to health and I’m having a bit of trouble. I’m sort of familiar with If statements but not sure how to format them using Javascript. I want to be able to add 50 health if the players health is below 50 points, and if their health is at 50 or above i want to just make their health an even 100.
Here’s what I have:
(Scripts Below)
I also tried doing a If/Else statement but I also wasn’t sure how to do that.
Any help is appreciated and if I’m doing it completely wrong then just say so! 
Thanks.
system
2
function OnTriggerEnter(otherObject : Collider){
if(otherObject.gameObject.tag == “bonus1” && playerLives < 50){
Destroy(otherObject.gameObject);
playerLives += 50;
}
else if(otherObject.gameObject.tag == “bonus1” && playerLives >= 50){
Destroy(otherObject.gameObject);
playerLives = 100;
}
}
That should do it, I tested it and it works on my part.