justn Posted May 28, 2014 Share Posted May 28, 2014 Hi, I'm currently working on a vehicle shop, and I have just a small problem with getting the player money. ERROR: VehicleShop\client.lua:66: attempt to compare nil with number Line 66 in this code would be line 15 addEventHandler("onClientGUIClick",BuyCar_Window, function(b) if b == "left" then if source == BuyCar_Close then guiSetVisible(BuyCar_Window,false) showCursor(false) elseif source == BuyCar_Test then local GuiGetTestText = guiGridListGetItemText(BuyCar_Grid,guiGridListGetSelectedItem(BuyCar_Grid),BuyCar_VehName) if ( GuiGetTestText ) then end elseif source == BuyCar_Buy then local GuiGetBuyText = guiGridListGetItemText(BuyCar_Grid,guiGridListGetSelectedItem(BuyCar_Grid),BuyCar_VehName) local GuiGetBuyText1 = guiGridListGetItemText(BuyCar_Grid,guiGridListGetSelectedItem(BuyCar_Grid),BuyCar_VehPrice) if ( GuiGetBuyText ) then if getPlayerMoney() >= tonumber(GuiGetBuyText1) then else exports["TopBarChat"]:sendClientMessage("#FF0000* #00ff00You do not have enough money for this vehicle",255,255,255,true) end end end end end) Link to comment
Castillo Posted May 28, 2014 Share Posted May 28, 2014 It seems like "GuiGetBuyText1" is nil. Also, guiGridListGetItemText returns a string, not a number, use tonumber ( ) to convert it. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now