- Home /
Script help please
Hi i'm kinda new to scripting and i cant get this script to work correctly when i click r i dont gain any XP when i have that implemented though :P if someone could PLEASE go through the script and tell me wat i did wrong and maybe upload the correct version of the script! Thanksin advance for your help! (and if you find any other problems please comment them below!)
//XP You'll start out with!
var curXP : int = 0;
//XP Untill next LVL Up!
var maxXP : int = 100;
//LVL To start out with!
var curLVL : int = 0;
//LVL Untill prestiging!
var maxLVL : int = 10;
//Prestige To start out with!
var curPrestige : int = 0;
//Max prestige (maxLVL + maxPrestige = HIGHEST LEVEL POSSIBLE!)
var maxPrestige : int = 5;
//The text type of game object you will need to add in the game!
var lvlText: GUIText;
function Update () {
lvlText.text = " Level " + curLVL + " MaxLevel " + maxLVL + " XP " + curXP + " XPUntillNextLevel " + maxXP;
if (curXP == maxXP) {
levelup ();
}
if (curLVL == maxLVL) {
prestige ();
}
}
if(Input.GetKeyDown(" r ")) {
curXP += 10;
}
function levelup () {
curXP = 0;
maxXP = maxXP + 100;
curLVL ++;
}
function prestige () {
if (Input.GetKeyDown(" + ")) {
curLVL = 1;
curPrestige = 1;
curXP = 0;
}
}
Formatting your code properly will raise your chances of a nice answer ;).
The issue is likely the string you are passing to Get$$anonymous$$eyDown(). Try:
if (Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.R))
and
if (Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.Plus))
Note for future posts, please take the time to include a better description of what the code should do and what the code is currently doing. Also I formatted your code. In future select you code and use the 101/010 button to format the code for online display.
Answer by acemuzzy · Jul 11, 2013 at 09:18 PM
So what exactly happens? The GUI text doesn't increase?
Try passing a KeyCode to Input.GetKeyDown(), I'm not sure " r " is valid.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Changing Axis to Buttons 2 Answers
Animation Script Help 0 Answers
Is it possible to link character skill lists to a GUI, and if so, how? 3 Answers
gyroscope script problem. 1 Answer