game.ReplicatedStorage.Remotes.DepositATM.OnServerEvent:Connect(function(player) local Wallet = player.CurrencyFolder.Wallet.Value local Amount = tonumber(script.Parent.Parent.AMOUNT.Text) if Wallet >= Amount then player.CurrencyFolder.Wallet.Value = player.CurrencyFolder.Wallet.Value - Amount player.BankFolder.Bank.Value = player.BankFolder.Bank.Value + Amount end end)
Error: Attempt to compare nil and number
The problem is that the text only changes for the client, not the server, so you have to send the text through with the LocalScript. For example:
LocalScript
-- Insert LocalScript code here game.ReplicatedStorage.Remotes.DepositATM:FireServer(script.Parent.Parent.AMOUNT.Text)
ServerScript
game.ReplicatedStorage.Remotes.DepositATM.OnServerEvent:Connect(function(player, text) local Wallet = player.CurrencyFolder.Wallet.Value local Amount = tonumber(text) if Wallet >= Amount then player.CurrencyFolder.Wallet.Value = player.CurrencyFolder.Wallet.Value - Amount player.BankFolder.Bank.Value = player.BankFolder.Bank.Value + Amount end end)
It says Attempt to compare nil and number
because the text is equal to nothing on the server's side. For more information click here