PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience
Collapse Sidebar

RemoveDefaultLoadingScreen

Immediately removes the default Roblox loading screen. Note if any object has been placed in ReplicatedFirst, the default loading screen will remove after 5 seconds regardless if this function has been called or not.

Developers should run this function from a LocalScript in ReplicatedFirst, as scripts in ReplicatedFirst will execute before anything else.

It is advised to not remove the default loading screen unless the developer wishes to display their own loading screen as an alternative. If the default screen is removed without replacement users will be able to see geometry loading in the background.

Returns

Return Type Summary

Code Samples


Custom Loading Screen

This sample is a simple demonstration of how a custom loading screen can be implemented. To run this code it should be placed in a LocalScript and parented to ReplicatedFirst.

In this example, a basic loading screen will be created and shown until the game has loaded (for a minimum time of 3 seconds). Developers may wish to expand on this with more elegant GUI elements. When doing so ensure that all such elements are parented to ReplicatedFirst and fetched using Instance/WaitForChild to ensure they replicate correctly.

    local Players = game:GetService("Players")
    local ReplicatedFirst = game:GetService("ReplicatedFirst")
    
    local localPlayer = Players.LocalPlayer 
    local playerGui = localPlayer:WaitForChild("PlayerGui")
    
    local MIN_TIME = 3
    
    -- create a basic loading gui
    local screenGui = Instance.new("ScreenGui")
    local textLabel = Instance.new("TextLabel", screenGui)
    textLabel.Text = "Loading"
    textLabel.Position = UDim2.new(0.5, 0, 0.5, 0)
    textLabel.AnchorPoint = Vector2.new(0.5, 0.5)
    textLabel.Size = UDim2.new(1 , 0, 1, 100) -- make sure the topbar is covered
    textLabel.FontSize = Enum.FontSize.Size14
    screenGui.Parent = playerGui
    
    -- hide the default loading screen 
    ReplicatedFirst:RemoveDefaultLoadingScreen()
    
    -- loop
    local count = 0
    local startTick = tick()
    while true do 
    	local timeElapsed = tick() - startTick
    	-- if the game has loaded and the minimum time has elapsed then break the loop
    	if game:IsLoaded() and timeElapsed > MIN_TIME then
    		break
    	end
    
    	-- animate the text 
    	textLabel.Text = "Loading " .. string.rep(".",count)
    	count = (count + 1) % 4
    
    	wait(.3)
    end
    
    -- destroy the loading screen
    screenGui:Destroy()