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

Teleportservice specific players problem?

for _,v in pairs(script.Parent.Parent.Parent.Parent.Parent.Players:GetChildren()) do
   -- game:GetService('TeleportService'):Teleport(4577231039, game.Players[v.Name])
print"teleported!"
game:GetService('TeleportService'):TeleportPartyAsync(4577231039, v.Name)
end

I'm trying to teleport all players into a place in the same server. But it says "unable to cast object".

1 answer

✓ Accepted answer

I'm pretty sure the second parameter of TeleportPartyAsync is a player table.

Try doing this instead:

local player_list = game:GetService('Players'):GetPlayers()

game:GetService('TeleportService'):TeleportPartyAsync(4577231039, player_list)

Fixed:

local GROUP_ID = 1010101

local player_list = {}
for _, player in next, game:GetService('Players'):GetPlayers() do
	if player:IsInGroup(GROUP_ID) then 
		table.insert(player_list, player)
	end
end

if #player_list > 0 then
	game:GetService('TeleportService'):TeleportPartyAsync(4577231039, player_list)
end

3 comments

0

Yes, but I'm trying to teleport all the players in a group. But that script only teleports all players.

0

Try the new code I added

0

Oh... Thanks. :) I appreciate your help...

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