Trouble teleporting player after loading screen

Im having trouble teleporting a player once they finish loading into the game. the script (given down below) has no errors but doesnt teleport the player when i test it for some reason.
How do i fix this?

ive tried using both teleport() and teleportAsync()

this is inside a local script in the replicated first

local contentProvider = game:GetService("ContentProvider")
local ui = script:WaitForChild("ScreenGui"):Clone()

repeat wait() until game:IsLoaded()

local assets = game:GetDescendants()
local maxAssets = #assets

local plr = game.Players.LocalPlayer
local plrGui = plr:WaitForChild("PlayerGui")

local TeleportService = game:GetService("TeleportService")
local teleportOptions = Instance.new("TeleportOptions")
teleportOptions.ShouldReserveServer = true


ui.Parent = plrGui --Loading Began\

ui:WaitForChild("Frame"):WaitForChild("Loading").Text = "1/"..maxAssets
wait(0.5)

for i, assetToLoad in assets do
	contentProvider:PreloadAsync({assetToLoad})
	ui:WaitForChild("Frame"):WaitForChild("Loading").Text = i.."/"..maxAssets
end --Loading Finished

--Tele player here
if workspace.TelePlayers == true then
	TeleportService:TeleportAsync(16740888388, {plr}, teleportOptions)
end

wait(3)
ui:Destroy()
1 Like

hey @fastslug08 , i guess the problem about TeleportService:TeleportAsync()

Just change it little bit like using if workspace.TelePlayers == true and i == maxAssets then in teleport section

if workspace.TelePlayers == true and i == maxAssets then
		-- do TP
	end

couse game data’s,props and scripts should loaded.

1 Like

hi, I tried this and unfortunately it didn’t work, have I done something wrong?

ive fixed it, it only works from the roblox app its self though and not from studio.
and for some reason it gives me this error when i play test it…
image
why is this?

Soo, Check if api’s are being used, and I don’t know if it will work but you can public your project from private to public. Its can be the problem

also make sure that the game to be teleported is public, this can also cause problems.

thanks, API’s are turned on in the studio, and the game is public. so there should be no problems. also im only teleporting the player to a ‘place’ inside the game not another game so it should be fine, however this error is still happening…