-
What do you want to achieve?
I want to make a loading that’s instant, whenever someone plays needs to see the loading screen. -
What is the issue?
I have some videos below so you can understand what I mean, I have no loading screen for 50-150ms and it isn’t the best. -
What solutions have you tried so far?
I didn’t find any solution other than making the player spawn directly with an UI (image.Visible = true) but I don’t think it’s the best answer to my issue, i’m sure there’s a better way to do so. Just want to know what possibilities I have to fix this.
Sorry for messy code but here’s my full script:
-- Services
local players = game:GetService("Players")
local replicatedFirst = game:GetService("ReplicatedFirst")
local contentProvider = game:GetService("ContentProvider")
local soundService = game:GetService("SoundService")
local tweenService = game:GetService("TweenService")
-- Disable roblox loading screen
replicatedFirst:RemoveDefaultLoadingScreen()
-- Local services
local player = players.LocalPlayer
local playerGui = player.PlayerGui
-- Gui
local blackTransiFrame = playerGui:WaitForChild("BlackTransiFrame")
-- Main frame
local loadingScreen = script:WaitForChild("LoadingScreen"):Clone()
loadingScreen.Parent = playerGui:WaitForChild("BlackTransiFrame")
-- Sub frames
local loadingText = loadingScreen:WaitForChild("loadingText")
local loadingBar = loadingScreen:WaitForChild("LoadingFrame"):WaitForChild("LoadingBar")
local fullBlackFrame = blackTransiFrame:WaitForChild("Frame")
-- SFX load
local UISFX = soundService:WaitForChild("SFX"):WaitForChild("UI")
local successLobbySFX = UISFX:WaitForChild("SuccessLobby")
-- Every main assets
local assets = game:GetChildren()
-- Load them
for index, asset in pairs(assets) do
loadingText.Text = "Loading ".. asset.Name.."..."
contentProvider:PreloadAsync({asset})
-- Info
local progress = index / #assets
-- Tween the bar
local tween = tweenService:Create(
loadingBar,
TweenInfo.new(0.25, Enum.EasingStyle.Linear),
{ Size = UDim2.new(progress, 0, 1, 0) }
)
tween:Play()
-- On then put the bar to visible
loadingBar.Visible = true
end
-- Loading completed
local tweenBarColor = tweenService:Create(loadingBar,
TweenInfo.new(1.2, Enum.EasingStyle.Quad, Enum.EasingDirection.Out),
{BackgroundColor3 = Color3.fromHex("#35FF46")})
-- Tween bar
tweenBarColor:Play()
-- Changing text + play SFX
loadingText.Text = "Loading completed!"
loadingBar.Size = UDim2.new(1, 0, 1, 0)
successLobbySFX:Play()
-- Waiting end of the bar + Little delay before black frame
tweenBarColor.Completed:Wait()
task.wait(0.325)
-- Tween everything for a smooth ending with tween
local tweenBlackFrameIn = tweenService:Create(fullBlackFrame,
TweenInfo.new(0.7, Enum.EasingStyle.Quart, Enum.EasingDirection.Out),
{BackgroundTransparency = 0})
tweenBlackFrameIn:Play()
tweenBlackFrameIn.Completed:Wait()
-- Delete the frame
task.wait(0.1)
loadingScreen:Destroy()
task.wait(0.375)
-- Has full view
local tweenBackgroundOut = tweenService:Create(fullBlackFrame,
TweenInfo.new(1.75, Enum.EasingStyle.Quart, Enum.EasingDirection.Out),
{BackgroundTransparency = 1}
)
tweenBackgroundOut:Play()
task.wait(2)
Here’s the video: