Argument #3 is nil

I’ve tried figure out long as is was possible, but I’m still stuck with the issue.

Mainly I wanna make the UI that let’s players change amount of Apple if it’s lower then it should warn them.

Local script:

local changedValue, changedAmount, message =  changeApples:InvokeServer("changeApple,appleToPass")

elseif message == "Max Apple Pack" and changedAmount ~= nil then
appleLabel:WaitForChild("messageLabel").Text = message

Server:

Events.changeAppleRemote.OnServerInvoke = (function(plr,whichAction,changedAmount,message)
	if whichAction == "changeApple" then
		if type(changedAmount) == "number" then
			if changedAmount < 3 then
					whichAction = message
					if message then
						message = "Too low! Lowest Apple set"
					end
			end

appleToPass is amountBox.Text on UI

The problem is when I type anything it gets nil value instead string one(message)

1 Like

perhaps you meant :InvokeServer("changeApple", tonumber(appleToPass))?
also you are not passing a message parameter but the server expects one.

No since it works pretty good instead the server one

The server code will error because you are passing the parameters incorrectly from the client.

Yeah I am talking about the message one which is why I’m confused

		local changedValue, changedAmount, message = changeApples:InvokeServer("changeApple",appleToPass)
		if changedValue == true and changedAmount ~= nil then
			sound:Play();
			amountBox.Text = tostring(changedAmount);
			number = tostring(changedAmount);
			if i ~= nil then
				i:Cancel();
			end;
			messageLabel:WaitForChild("messageLabel").Text = message;
			messageLabel.messageLabel.TextColor3 = Color3.fromRGB(0, 255, 0);
			messageLabel.messageLabel.Visible = true;
			hm = ts:Create(messageLabel.messageLabel, TweenInfo.new(3), {
				Visible = false
			});
			i:Play();
			return;
		end;
		if message == "Max Apple set" and changedAmount ~= nil then
			sound:Play();
			amountBox.Text = tostring(changedAmount);
			test = tostring(changedAmount);
			if hm ~= nil then
				hm:Cancel();
			end
			messageLabel:WaitForChild("messageLabel").Text = message;
			messageLabel.messageLabel.TextColor3 = Color3.fromRGB(0, 255, 0);
			messageLabel.messageLabel.Visible = true;
			hm = ts:Create(messageLabel.messageLabel, TweenInfo.new(3), {
				Visible = false
			})
			hm:Play()
			return
		end

It’s the local, what’s wrong with it? It’s works perfect instead server side.

I will be grateful to anyone who could help me with this problem, I can’t understand it in any way after spending 1 hour on it.

The server is expecting a message. Get rid of that and the script should at least run since the 3rd argument is going to be nil since you provided no parameter value in line :

So change it to

local changedValue, changedAmount, message = changeApples:InvokeServer(“changeApple”, appleToPass, **YOUR MESSAGE GOES HERE as the server expects it**)

I tried do it as well and still nothing. The thing is server puts print on but not from client side.

What and where on your code does the server return to those variables on the client?

		local appleToPass = tonumber(amountBox.Text)
		if appleToPass == nil then
			amountBox.Text = amountBox
			dSound:Play()
			return
		end
		local changedValue, changedAmount, message = changeApples:InvokeServer("changeApple",appleToPass)

1st = Server side, 2nd = local:

Did a very simple code to check what’s wrong and still nothing, there are the code of 1st screenshot:

Local

Server

1 Like

You actually have to return the message variable in the server side and it should work

After the print statement, just do

return message
1 Like

Oh my bad, I completely forgot about return, let’s see

1 Like

Hopefully it works :)!!!

1 Like

Works at the simple code that I was testing, but in mainly it’s still broken weird

Did you add the return on the other ones as well? In their designated areas?

Thank you! I figured out and now fixed the my issue!

Good to hear, sorry I was at work!