Issue with using > and <

Im setting up my rewards script based on a level, and if the player claims a higher level first I need them to be able to still claim the lower level without it changing the name of their “claimedlevel” objectvalue inside a plater data folder (so it still registers they’ve claimed a higher level previously), so I thought id use the following script to detect if the players new level is less than the current level which then wouldnt change the name of their claimedlevel:

However in game when claiming level 10 first and then level 5 after I get this:
image
and the value inisde the playerdata still changes from 10 to 5 instead of staying at 10

levelclaimed comes from this localscript inside a gui:
image

First of all, please indent your code correctly, it is difficult to read.

The issue with your code is that you are comparing strings instead of numbers.

This script will produce the following output:

value1 = "5"
value2 = "10"

if value1 > value2 then
    print(value1 .. ">".. value2)
elseif value1 < value2 then
    print(value1 .. "<".. value2)
end

--// Output \\--
5>10

I am not sure why the value of currentlevel is stored in the Name of ObjectValue. I believe it is better to store the value in an IntValue. The name of an object is a string. The levelclaimed is also a string since you set the value to "10".

To solve this issue, you can either change the values of currentlevel and newlevel to a number, or use tonumber().

tonumber solved it perfectly, thanks.