Loading screen systeme

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

local Template = script.Template

local loadingGui = Template.LoadingGui:Clone()
local loadingScreenFrame = loadingGui.LoadingScreen
local logoImage = loadingScreenFrame.LogoImage

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

ReplicatedFirst:RemoveDefaultLoadingScreen()

local function tweenPlay(tween: {Tween} | Tween, waitToCompleted: boolean?)
	local t = {}

	if type(tween) == "table" then t = tween else t = {tween} end

	for _, v: Tween in t do
		v:Play()

		v.Completed:Wait()
	end

	return true, "Completed Tween"
end

local tweenOpen = {
	TweenService:Create(loadingScreenFrame, TweenInfo.new(0.5, Enum.EasingStyle.Linear, Enum.EasingDirection.Out), {Size = UDim2.new(1, 0, 1, 0)}),
	TweenService:Create(logoImage, TweenInfo.new(2, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, -1, true), {ImageTransparency = 1})
}

local tweenClose = {
	TweenService:Create(logoImage, TweenInfo.new(0.5, Enum.EasingStyle.Linear, Enum.EasingDirection.Out), {ImageTransparency = 1}),
	TweenService:Create(loadingScreenFrame, TweenInfo.new(0.5, Enum.EasingStyle.Linear, Enum.EasingDirection.Out), {Transparency = 1})
}

local co = coroutine.create(function()
	tweenPlay(tweenOpen, true)
end)

local function onLoading()
	loadingGui.Parent = playerGui
	loadingScreenFrame.Visible = true
	
	coroutine.resume(co)
	
	task.wait(5)

	if not game:IsLoaded() then game.Loaded:Wait() end
	
	local success, msg = tweenPlay(tweenClose, true)
	
	if success then
		print(msg)
	end

	loadingScreenFrame:Destroy()
end

task.spawn(onLoading)

cool.
whyd you make it so much fancier

2 Likes

ls that a compliment??? ^^ thanks for your reply

1 Like