Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Level System no errors but I don't gain levels only xp?

Asked by 9 years ago

Here is the code

001function onXPChanged(player, XP, Level)
002    if XP.Value>=Level.Value * 80 + XP.Value then
003        Level.Value = Level.Value + 1
004    end
005end
006 
007function onXPChanged2(player, XP2, Level2)
008    if XP2.Value>=Level2.Value * 80 + XP2.Value then
009        Level2.Value = Level2.Value + 1
010    end
011end
012 
013function onLevelUp(player, XP, Level)
014    if player.Character~=nil then
015        for i = 1,5 do
View all 100 lines...

1 answer

Log in to vote
0
Answered by
dyler3 1510 Moderation Voter
9 years ago

The reason your levels aren't going up is pretty simple:

You told the game that if the XP is greater than or equal to the XP + Level80, then it would level them up.The main thing that's wrong here is that your telling it to go up if a value is larger than itself plus something else, which will clearly never be the case (unless your adding a negative)


To fix this, you simply need to change the functions to this:

01function onXPChanged(player, XP, Level)
02    if XP.Value>=Level.Value * 80  then --I took out '+XP.Value' which was causing the problem
03        Level.Value = Level.Value + 1
04    end
05end
06 
07function onXPChanged2(player, XP2, Level2)
08    if XP2.Value>=Level2.Value * 80  then --Same as above ^
09        Level2.Value = Level2.Value + 1
10    end
11end

Anyways, the script should work correctly now. If you have any further problems/questions, please leave a comment below. Hope I helped :P

0
I found it out lol feel dumb namerplz 42 — 9y
Ad

Answer this question