Argument two missing or nil when teleporting

Hi, I have a VIP server system which teleports players to other’s vips. When the player clicks the join button it fires a remote event but It gives an error argument two missing or nil

Server script:

local DS = DataStoreService:GetGlobalDataStore()
local code = DS:GetAsync("ReservedServer")

newserver.OnServerEvent:Connect(function(plr)
	local bool = false
	for i,v in ipairs(servers) do
		if game.PrivateServerId == v.id and v.plr == plr.UserId then
			
			bool = true
			break
		end
		if v.plr == plr.UserId and v.id ~= game.PrivateServerId then
			TS:TeleportToPrivateServer(9619375620,v.server,{plr})
			bool = true
		end
	end
	if bool == false then
		
		code = TS:ReserveServer(9619375620)
		DS:SetAsync("ReservedServer",code)
		
		ServerUpdate(code,plr.UserId)
		TS:TeleportToPrivateServer(9619375620,code,{plr})
		
		
	
		
	end


	
end)



asktoinvite.OnServerEvent:Connect(function(plr)
	local success , err = pcall(function()
		TS:TeleportToPrivateServer(9619375620 , code , {plr})
	end)
	if not success then
		warn(err)
	end
end)

Client script:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local event = ReplicatedStorage:WaitForChild("AskToInvite")
local button = script.Parent

button.MouseButton1Click:Connect(function()
event:FireServer()
end)

Any help would be appreciated, thanks!

wrong category mate, put it in #help-and-feedback:scripting-support. You’ll get more answers than posting it here

I accidently put it in creations feedback, sorry.

1 Like

On what line are you receiving the error?

the line where it warns(err)
[char limit]

The key at “ReservedServer” seems to be nil. Are you sure that you are writing data to it successfully before the asktoinvite remote event is fired?

Yes, I am sure, but I don’t know why it isnt working