Argument 1 Missing or Nil for InvokeServer()

Hi there! So I am currently creating a follow system, where a player can follow a friend to another server. I don’t think that has much to do with the problem, but I thought to just give some context.

Anyways, part of the follow system sends a request from the client with a remote function, and it is supposed to return whether it was successful or not. Here is the client sided script:

function FriendsModule.Follow(Player,TeleportedToName)
	if debounce == false then
		debounce = true
		script.Parent.Loading.TextLabel.Visible = true
		script.Parent.Loading.TextLabel.Text = "Loading..."
		local result = game.ReplicatedStorage.TeleportEvent:InvokeServer(TeleportedToName, true)
		if result == false then
			script.Parent.Loading.TextLabel.Text = "Teleport Failed, please try again..."
			script.Parent.Loading.TextLabel.Visible = false
			script.Parent.Loading.TextLabel.Text = "Teleporting..."
		debounce = false

With the following being the part where I am invoking the server:

local result = game.ReplicatedStorage.TeleportEvent:InvokeServer(TeleportedToName, true)

From this line of code, I am getting the error Argument 1 Missing or Nil, which makes no sense.

firstly, as you can see from what I printed just before, i checked the first variable, and it is not nil, it prints out the name fine. Secondly, since this is invoking the server, i do not need to send through a player instance, which seems to be most people’s problems. Furthermore, this is on the client, not the server, which means the server code should be fine, but I’ll paste it here anyways:

local function Teleport(plr, plr2name, state)
	if state == true then
		local plr2UserId = getUserIdFromUsername(plr2name)
		local currentInstance, _, placeId, jobId
		local success, errmsg = pcall(function()
			currentInstance, _, placeId, jobId = game:GetService("TeleportService"):GetPlayerPlaceInstanceAsync(plr2UserId)
		if success then
			local success1, errmsg1 = pcall(function()
				game:GetService("TeleportService"):TeleportToPlaceInstance(placeId, jobId, plr)
			if not success1 then
				return false
			return false

game.ReplicatedStorage.TeleportEvent.OnServerInvoke = Teleport

The above is the server sided code. I cut it down a bit so it’s not too long, but everything important is there.

So I’m not too sure what could be happening. Like I said before, this error is happening on the client sided script, and the first argument definitely isn’t missing or nil.

Any help would be appreciated :slight_smile:

1 Like

you need to add a statement aka somewhere in ur code there is a statements in whose 1st statement is nil

Hi. Sorry for late reply, I went away for a while.

I added a statement that checks, and I still get the error.

lol a reply after 17 freaking days i forgot what the problem even was

also the error is cause somewhere in your script where you use InvokeServer you didnt added the first statement

Nope, the error was caused by that exact line, where the first argument is definately not nil.

try printing the “first argument”