A strange error has been happening in my script. Every time I use a specific sign to compare strings my script just breaks down, but when I use anything else it’s fine but it’s not what I want.
Here is the script:
if plr.leaderstats[currency].Value >= price then
print(plr.Name.. " is hatching "..eggName)
plr.leaderstats[currency].Value -= price
plr.leaderstats.Eggs.Value += 1
return true
else
return false
end
end
I have tried changing the sign to “==” for example and it works but it is not at all what I want to do to achieve what I want. I am really stuck on this, someone told me it was an error with the returns but that makes no sense at all since it works when I use a different sign.
If you know anything please let me know, thank you!
Try changing plr.leaderstats.Eggs.Value += 1 to plr.leaderstats.Eggs.Value + 1 || This might be your problem, although I’m not too sure. Possibly just try it to see if I’m right, as it doesn’t hurt! (:
if plr.leaderstats[currency.Value].Value >= price.Value then
print(plr.Name.. " is hatching "..eggName)
plr.leaderstats[currency.Value].Value -= price.Value
plr.leaderstats.Eggs.Value += 1
return true
else
return false
end
end
Small correction. As long as the string value is a number you can still do math with it and a number value. You just cannot compare them using >, <, >=, <= operators.
For example
local str = "1"
local n = 2
local x = str + n -- this = 3