Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why is my reserve server event getting the error "unable to cast value to object"?

I am attempting to make a script that teleport all the people on a brick to a certain server. It goes completely fine up until we get to the reserveserver event where it then shows an error "HTTP 403 (Forbidden)"

local TweenService = game:GetService("TweenService")
local TeleportServce = game:GetService("TeleportService")

local OpenTeleportUI = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvents").OpenTeleportUI
local UpdateTeleportUI = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvents").UpdateTeleportUI

local GameId = 4815315578

local debounce = false

local CloseDoor = TweenService:Create(script.Parent.Parent.MovingDoor,TweenInfo.new(2.5,Enum.EasingStyle.Linear,Enum.EasingDirection.In,0,false,0),
	{Position = Vector3.new(395.354, 76.527, 18.753)}
)

local OpenDoor = TweenService:Create(script.Parent.Parent.MovingDoor,TweenInfo.new(2.5,Enum.EasingStyle.Linear,Enum.EasingDirection.In,0,false,0),
	{Position = Vector3.new(394.924, 76.527, 9.341)}
)

local currentPlayerTable = {}

script.Parent.Touched:Connect(function(hit)
	if hit then
		if hit.Parent:FindFirstChild("Humanoid") then
			if debounce == false then
				debounce = true
				wait(.5)
				local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
				OpenTeleportUI:FireClient(player)
				table.insert(currentPlayerTable,player)
				local P1 = currentPlayerTable[1] 
				local P2 = currentPlayerTable[2]
				local P3 = currentPlayerTable[3] 
				local P4 = currentPlayerTable[4] 
				UpdateTeleportUI:FireAllClients(P1,P2,P3,P4)
				if #currentPlayerTable == 1 then
					local ReserveServer = TeleportServce:ReserveServer(GameId)
					for i,player in pairs(currentPlayerTable)do
						wait()
						print("player"..player.Nmae)
						TeleportServce:TeleportToPrivateServer(GameId,ReserveServer,player)					
					end					
				end
			end
		end
	end
end)



1 answer

:TeleportToPrivateServer() requires an array of Player Objects to teleport, wrap the user you wish to send to a Reserved Server with square braces:

TeleportService:TeleportToPrivateServer(GameId, ReserveServer, {Player})

This discussion is preserved as it was. New answers, comments, and votes are closed.