#how to make sure that parts are loaded on the players screen before teleporting them

1 messages · Page 1 of 1 (latest)

green grotto
#

currently it teleports the player once everything is preloaded using preloadAsync, and i even make sure to go through the folder with the map parts, but whenever you spawn in it still visually loads in the map and you can see off the edge. is there any way to stop this from happening ? plz

#

neccesary code -

local ReplicatedFirst = game:GetService("ReplicatedFirst")
local ContentProvider = game:GetService("ContentProvider")

ReplicatedFirst:RemoveDefaultLoadingScreen()

local player = Players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")

local loadingScreen = script:WaitForChild("LoadingScreen"):Clone()
loadingScreen.Parent = playerGui

local frame = loadingScreen:WaitForChild("Background")
local loadingText =  frame:WaitForChild("LoadedX")
local percent = frame:WaitForChild("Percent")
local classification = loadingScreen:WaitForChild("Classification")

local introsound = classification:WaitForChild("LoadingBackrooms")
local ding = game:WaitForChild("ReplicatedStorage"):WaitForChild("Sounds"):WaitForChild("ding")
local assets = game:GetChildren()



for i, asset in pairs(assets) do
    task.wait(0.01)
    loadingText.Parent = loadingScreen
    
    loadingText.Text = "(".. i .. "/" .. #assets .. ") " .. " Loading " .. asset.Name 
    
    ContentProvider:PreloadAsync({asset})
    ding:Play()
    
    local progress = i / #assets
    percent.Text = math.round(progress*100) .. "%"
    
end    

local spawnedChunks = game.Workspace.LoadedChunks.Chunks:GetChildren()
local playerLoaded = game:WaitForChild("ReplicatedStorage"):WaitForChild("events"):WaitForChild("playerLoaded")

playerLoaded.OnClientEvent:Connect(function()
    
    for i, spawnedChunk in pairs(spawnedChunks) do
    
        task.wait(0.01)
        loadingText.Parent = loadingScreen

        loadingText.Text = "(".. i .. "/" .. #spawnedChunks .. ") " .. " Loading " .. spawnedChunk.Name 

        ContentProvider:PreloadAsync({spawnedChunk})
        
        local progress = i / #spawnedChunks
        percent.Text = math.round(progress*100) .. "%"

    end    
end)


loadingText.Text = "Loading Complete"
#

rest is just intro animation

thin shell
#

u didnt ask the script if the assets are fully loaded

#

as example I have a loading screen that first checks if i == #Assets.

#

then it does every animation