Declaring IntValue through RemoteEvent issues

Hey there everyone! Been having issues with using RemoteEvents and looking to get some help with it. I am making an ATM system in my game and I am having issues with sending the amount the player selects to the server script, not sure how else I can explain it but hopefully the code will clear things up.

Local Script (from player gui)

local depositButton = script.Parent
local atmRemoteEvent = game.ReplicatedStorage.atmDeposit

depositButton.MouseButton1Click:Connect(function()
	atmRemoteEvent:FireServer(script.Parent.Amount)
end)

Server Script

-- Services

local ReplicatedStorage = game:GetService("ReplicatedStorage")

-- Variables

local atmDeposit = ReplicatedStorage:WaitForChild("atmDeposit")
local atmWithdraw = ReplicatedStorage:WaitForChild("atmWithdraw")

-- Functions

local function atmDepositFunc(plr, amount)
	if plr.leaderstats.Cash.Value >= amount.Value then
		plr.BankCash.Value += amount.Value
		plr.leaderstats.Cash.Value -= amount.Value
	else
		print("Not enough to withdraw")
	end
end

local function atmWithdrawFunc(plr, amount)
	if plr.BankCash.Value >= amount.Value then
		plr.BankCash.Value -= amount.Value
		plr.leaderstats.Cash.Value += amount.Value
	else
		print("Not enough to withdraw")
	end
end

atmDeposit.OnServerEvent:Connect(atmDepositFunc)
atmWithdraw.OnServerEvent:Connect(atmWithdrawFunc)

The issue I get with this is that in the server script, it defines the ‘amount’ as a nill value rather that the amount from the IntValue inside the button. I am fairly new to using remote events, so if anyone can help clear up how to properly declare the amount value from the local script to the server script that will be very helpful!

Thank you and have a happy new year!

I don’t recommend sending an Instance itself to the server from client. Instead send the value.

1 Like

Thanks for the help, solved my issue! It’s so easy to overlook problems as small as this haha

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.