I’m having this problem in a script where I’m comparing 2 Values but it says “attempt to compare string <= number”
This is my code below:
When the script removes Value off the player it works but when it wants to compare it breaks.
I’m having this problem in a script where I’m comparing 2 Values but it says “attempt to compare string <= number”
This is my code below:
This is because either currency.Value or cost is a string and not a number, so it cannot be compared with >=. To fix this you can change the value to a number like so:
if tonumber(currency.Value) >= tonumber(cost) then
or you can make sure that you are sending a number through the RemoteEvent and not a string by accident. I suspect that you are using a StringValue and not a NumberValue by mistake, so I would check that as well.
In addition to this, if the cost variable is a number in quotations, (e.g. Local cost = "10"), cost will be a string instead if a number.