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()
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…
why is this?
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…