Players fall off the map when they are teleported within a place because some of the models aren’t loaded yet. Any solution to this issue?
You could possibly use
ContentProvider:PreloadAsync() function as that will yield/stop the current script in order to properly do it’s function
What this does, is that it loads all of the specified Objects/Instances you want it to properly load through something called an Array (Or a group of objects)
local ContentProvider = game:GetService("ContentProvider") local MapObjects = workspace.Map:GetDescendants() --Replace this with your Map -- GetDescendants() returns back an Array of Objects local StartTime = os.clock() ContentProvider:PreloadAsync(MapObjects) local DeltaTime = os.clock() - StartTime print(("Preloading completed, took %.2f seconds"):format(DeltaTime)) -- Now Teleport all the Players Here
You could also use FireAllClients() and wait for the “.Loaded” event of the data model to fire before commencing the teleport, if you’re waiting for instances which are added/created dynamically then you should just add a generic yield like “task.wait(3)” or some other suitable delay length.
repeat task.wait() until #workspace.ClonedMap:GetChildren() == 100 --100 expected children of map
Here’s another potential idea you could use.
In addition to the above, you could also use Replication Focus, but there’s no guarantee that would load the content in time.
does this have to be done on the client side?
You could use RequestStreamAroundAsync() and put the teleport position in the argument of that function which streaming enabled will load parts around the position, although as stated from the api reference:
" Requesting streaming around an area is not a guarantee that the content will be present when the request completes, as streaming is affected by the client’s network bandwidth, memory limitations, and other factors."
though this should work for now
When your teleporting do this:
Do this on server, doing it on client will cause error
Note that the objects loaded, will not load out unless player have no memory