Quantcast
Channel: Latest Questions by eeveelution8
Viewing all articles
Browse latest Browse all 100

Shop system using Enum throws up errors.

$
0
0
This is a simplified part of the script where it doesn't work, enum Shoptype {R_Rock,R_Iron,R_Silver,R_Gold,R_Gems,R_Uranium,R_Voidium,R_Zarkotium,R_Omnium,ShipFuel,ShipHull,ShipMissiles}; var whichResource : Shoptype; var ThePlayer : PlayerScript; function OnMouseDown(){ if(sellbutton == true){ if(sellall == false){ if(ThePlayer.whichResource >= amount){ ThePlayer.whichResource -= amount; ThePlayer.Money += (price*amount); guiTexture.color = Color(0.25,0.25,1,1); }else if(ThePlayer.whichResource < amount){ guiTexture.color = Color(1,0.25,0.25,1); } }if(sellall == true){ if(ThePlayer.whichResource >= 1){ theamount = ThePlayer.whichResource; ThePlayer.Money += (price*theamount); ThePlayer.whichResource -= theamount; guiTexture.color = Color(0.25,0.25,1,1); }else if(ThePlayer.whichResource == 0){ guiTexture.color = Color(1,0.25,0.25,1); } } }else if(sellbutton == false){ if(ThePlayer.Money >= price){ ThePlayer.whichResource += theamount; ThePlayer.Money -= price; guiTexture.color = Color(0.25,0.25,1,1); }else if(ThePlayer.Money < price){ guiTexture.color = Color(1,0.25,0.25,1); } } } it puts this error at the line, if(ThePlayer.whichResource >= amount){ "NullReferenceException: Object reference not set to an instance of an object" not sure what's going on here, I don't work with enums alot.

Viewing all articles
Browse latest Browse all 100

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>