It’s a little hard for me to understand what you’re doing and what you’re trying to do. Others are more willing to help if you use code tags in the future.
That said, I think you’re using “||” (or) when you mean to use “&&” (and) in your “if statements”
EDIT:
To get a random number, use System.Random.Range() or UnityEngine.Random.Range()
oright thank u but i am 100% new to unity but i know some c# and what i am trying to do is if i level past 10 the experenice i need should change to 100+ for each level however it doesnt change ?`and i tried || and && both non of them work when i press a button?.
and also if u know how i can make sure i wont get random numbers if i dont use
I think you have too many if checks and it’s making things over complicated. Just try this:
public void RequiredXpToLvl()
{
// Stop the function early if you don't have enough exp
if (newPlayer.currentexp < newPlayer.requiredexp) return;
if (level <= 10)
{
// require 50 more exp if you're level 10 or less
requiredexp += 50;
}
else
{
// add 100 more exp if you're above level 10
requiredexp += 100;
}
}
requiredexp should not be a random number unless you set it to one. Maybe you’re not setting it when you create it?