Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Invalid list of players to teleport error, how do I fix this?

Asked by 1 year ago

In my code to teleport players from a main game to a place connected to the main experience I have a "Invalid list of players to teleport." error. How do I fix this?

local teleport = game.ReplicatedStorage:WaitForChild("Teleportplayer") local teleportservice = game:GetService("TeleportService") local placeId = 11905398683 local players = game:GetService("Players") local player = players:GetPlayers()[1]

teleport.OnServerEvent:Connect(function() teleportservice:TeleportAsync(placeId,{player}) end)

0
I don't know but for some reason my text was misformatted when copying and pastying, however it is properly formatted in the script. eemmeettt 5 — 1y
0
Perhaps 'player' is nil. As you're declaring it at the start of the script, the player may not be loaded; try printing 'player' and see what it prints. xInfinityBear 1777 — 1y

1 answer

Log in to vote
0
Answered by 1 year ago

The player was not yet loaded, if you put a wait(let's say 5) this gives the player enough time to load.

0
It would be better to put the player inside the event and check if it is not nil, instead of adding a wait. xInfinityBear 1777 — 1y
Ad

Answer this question