ID:2766801
 
(See the best response by Shadowkaroth.)
i have made a credit system but the problem is buying things with negative credits still works, here's a vending machine i tried to stop the usage of 0 or negatives but the things Ive tried either not worked or errored out

obj/vendingMachine
icon = 'interactables.dmi'
density = 1
icon_state = "vm"
verb
insert_credit()
set src in oview(1)
if(usr.credit =< 0)
Close()
usr << "ding"
usr.give_credit(-1)
var/soda = pick(
/obj/green_soda,
prob(16)
/obj/blue_soda,
prob(16)
/obj/Tele_soda,
prob(16)
/obj/JimSuit_soda,
prob(16)
/obj/RED_soda,
prob(16)
/obj/soda)
new soda(usr.loc)
Your verb still continues after the if statement. If you want to end the verb if credit is less than or equal to 0, you can add a return.

You may also put in the soda pick as a 'else' condition.
Best response
Your operators are backwards for sure <= "Less than or Equal to"

You also need to escape out of the entire function at that point. "return" or use an else staement and indent the block of code after the if() to be only executed otherwise "else"