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

Unable to cast value to objects?

This is the code i'm using to teleport players to a reserved server instance and it's not working. Whenever I attempt to teleport players (max player count of 1) I get Unable to cast value to object(s).

local TS = game:GetService("TeleportService")
local Players = game:GetService("Players")
local p = Players:GetPlayers()

if game.PrivateServerId ~= "" then
	game.ServerStorage.isVIP.Value = true
	reserve = TS:ReserveServer(IDREDACTED)
	wait(5)
	TS:TeleportToPrivateServer(IDREDACTED,reserve,{p})
end

2 comments

0

what line

0

09

1 answer

✓ Accepted answer

What you're passing as an argument for the list of players to be teleported is an array of an array of players to be teleported because Players:GetPlayers() already returns the players in an array, when it should just be an array with the players:

local p = Players:GetPlayers()
TS:TeleportToPrivateServer(IDREDACTED, reserve, p)

1 comment

0

DOOBUS?!?!?! I THOUGHT YOU LEFT ROBLOX O_O

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