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..."
print(TeleportedToName)
local result = game.ReplicatedStorage.TeleportEvent:InvokeServer(TeleportedToName, true)
if result == false then
script.Parent.Loading.TextLabel.Text = "Teleport Failed, please try again..."
wait(2)
script.Parent.Loading.TextLabel.Visible = false
else
script.Parent.Loading.TextLabel.Text = "Teleporting..."
end
debounce = false
end
end
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)
end)
if success then
local success1, errmsg1 = pcall(function()
game:GetService("TeleportService"):TeleportToPlaceInstance(placeId, jobId, plr)
end)
if not success1 then
return false
end
else
return false
end
end
end
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