r/ComputerCraft • u/Drum__Stick • Nov 25 '25
problem with code
(BEEN FIXED) hey guys im having a problem with my code im working on a credit deposit and withdrawal for a casino on a server im in and i have no clue whats happened, it was working completely fine then i started working on the deposit button but it broke and have no clue what happened. the error is showing up on line 251 and im lost on fixing it, can anyone help?

here's my pastebin so you can look at all of it https://pastebin.com/DkW385R4
4
Upvotes
View all comments
Show parent comment
2
u/Insurgentbullier NIH patient Nov 27 '25
oh mb i was being unclear about line numbers. The problem is that you are calling the same function twice.
On line 39, you call:
`saveCreditsToDisk(loadCreditsFromDisk() + (item.count * diToCredit))`
This is good.
But then on line 40 you call:
`saveCreditsToDisk()`
This is not good, because you are overwriting your previous actions on line 39. And no argument is provided, so the param (credits variable) turns to `nil`.
Meaning:
`file.writeLine(tostring(credits)) -- Write the credits as a string`
when evaluated becomes: `file.writeLine("nil")`.
So the content of credits.txt is literally "nil". And that's not a number when using tonumber(...).