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!
game.ReplicatedStorage.BankingEvents.CheckWithdraw.OnServerEvent:Connect(function(player)
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
end
end)
@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.
script.Parent.MouseButton1Click:Connect(function(player)
local player = game.Players.LocalPlayer
game.ReplicatedStorage.BankingEvents.CheckWithdraw:FireServer(player)
end)
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
end
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