Getting error "Argument 1 missing or nil" for no apparent reason

I am currently attempting to make a face inserter using the faceID. However, for whatever reason, it will not function as intended and keeps sending “Argument 1 missing or nil” despite all variables on line 5 being defined.
image

Here is the script: (annotated)

I looked at a bunch of other devforum posts, but none of them appeared to be relevant to this specific situation.

In case it is needed, here is the localscript as well:


Is this a misunderstanding of how LoadAsset works? Or some other mistake that I’m just failing to notice

The first argument is nil because text.Text really is nil on the server. Changes to it in a local script don’t replicate. What you can do is send text.Text as an argument. On the server-side, make sure the information a client sent is valid.

local text = tonumber(text)
if text then ... end

Edit.

You should also not send the text on every change. If this is a TextBox, consider reacting to focus loss.

text.FocusLost:Connect(function(enterPressed)
	if enterPressed and tonumber(text.Text) ~= nil then
		FaceChanged:FireServer(text.Text)
	end
end)
1 Like

Try this in the local script:

text.Changed:Connect(function()
  if (text.Text)~=""and tonumber(text.Text)~=nil then
       FaceChanged:FireServer(text.Text)
  end
end)

and then directly use the ID in the server, don’t redefine it cause the text did not really change on server, rather on client.

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