"attempt to compare string <= number"

So I am making a banking system and have been trying hard to fix problems with the Withdraw function but keep getting errors that I fixed but can’t fix this one please help me!

	local Amount = tonumber(player.PlayerGui.ATMSystem.Checkings.Amount.Text)

	if player.data.Checkings.Value <= 0 then return end
	if player.data.Checkings.Value > 0 and player.data.Checkings.Value >= Amount then
		player.data.Checkings.Value = player.data.Checkings.Value - Amount


Is the text only numbers and nothing else?

Also, your error is trying to say that you’re trying to compare nothing to a number.

1 Like

Ye I am pretty sure. Also wait a minute? What?

player.data.Checkings.Value is nil. It says attempt to compare nil <= number, not string.

1 Like

I said, your error is saying your error trying to compare nothing to a number.

1 Like

@ItzMeZeus_IGotHacked is right since if there is text in the called string, I learned that the outcome will be nil. Check your local script to see if the input has non-numbers text in it.


Oh my goodness I am so dumb! I forgot to bring the Amount text from the the localscript over to the server script so now it thinks there is no text! I need to edit the remote event and I will see if it fixes that.

You can show us the part where you fire the remote event from the local script for us to help you.

	local player = game.Players.LocalPlayer

Yeah nothing important, I guess the problem is your backend.

1 Like

Wait what? Blackened impossible my scripts are from me!

Also FireServer() works without giving the player param, but you need it in the server script.

1 Like

No no I mean, backend means the main thing that controls behind the scenes. Malicious backend scripts are backend that serves the purpose of hacking.

1 Like

Ah, well I will try to fix this thing and see if it worked.


You can easily add String Patterns as a better check for numbers. As a example, for digits you would need %d. To get multiple digits and not just the first one of the string, add a + to your pattern.

Now, after this is done, easily check the string with string.match, for example

if string.match("Your Text!", "%d+") then
    -- Your code

I hope this helps you out with your problem!



Nonono No need for that it is already in one of my scripts.I just need to edit the remote event but thank you!

Okay but now I need help transferring the text from the client to the server.


You can easily add as many arguments to your RemoteEvent | Roblox Creator Documentation function. Just add your values in between the brackets of the client side, for example

RemoteEvent:FireServer("Your Text!")

After that is done, you need to reference the same exact RemoteEvent | Roblox Creator Documentation in the server.
If thats done, add a RemoteEvent | Roblox Creator Documentation event in the server. Important to know here is, the first argument passed is the player, after that are your own arguments.

This looks like this example:

RemoteEvent.OnServerEvent:Connect(function(player, YourArgument) 
    -- Code here

There you have your text as YourArgument passed and ready to use in the server.

Hope this could help you!


Thank you after 2 days of fixing this this helped me a lot!


Absolutely no problem, have fun developing!


1 Like