Money System Problem

So, I’m trying to make a menu where when you buy something it takes money away from you and If you don’t have enough money you can’t buy it.

[LUA]
function player_meta:TakeMoney( amount )
if self:HasMoney( amount ) then
self:SetPData( MoneyIdentity, self:GetPData( MoneyIdentity ) - amount );
self:SetNWInt( MoneyIdentity, self:GetPData( MoneyIdentity ) );
end;
end;

function player_meta:HasMoney( amount )
if self:GetPData( MoneyIdentity ) >= amount then – Line 34
return true;
else
return false;
end;
end;
[/LUA]
The only problem is that If I don’t have enough money it still lets me buy the item.
This is the Error I have:



moneysystem.lua:34] attempt to compare number with string


If someone could help me out that would be great.

which line is 34 in here?

**[G.tonumber

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=G.tonumber)**


    if self:GetPData( MoneyIdentity ) >= amount then -- Line 34  


is line 34
Also, can you explain how you would use tonumber? As you can tell I’m not the best with Lua.

[lua] if(20 > tonumber(“19”)) then print(“Yay”) end [/lua]

[lua]if tonumber(self:GetPData( MoneyIdentity )) >= amount then[/lua]

Oh, I get it now, Thank you very much