My custom loading screen lags as shown here:
It does lag in the normal Roblox client too.
Code
local Players = game:GetService("Players")
local ReplicatedFirst = game:GetService("ReplicatedFirst")
local player = Players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")
-- Instances:
local Loading = Instance.new("ScreenGui")
local Frame = Instance.new("Frame")
local Logo = Instance.new("ImageLabel")
local Ring = Instance.new("ImageLabel")
local Welcome = Instance.new("TextLabel")
-- Check if they're a new user:
--if player.AccountAge < 30 then
-- player:Kick("Your account is younger than 30 days.")
--end temp disable
--Properties:
Loading.Name = "Loading"
Loading.Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui")
Loading.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
Frame.Parent = Loading
Frame.BackgroundColor3 = Color3.fromRGB(35, 39, 42)
Frame.Size = UDim2.new(1, 0, 1, 0)
Frame.ZIndex = 1000
Logo.Name = "Logo"
Logo.Parent = Frame
Logo.AnchorPoint = Vector2.new(0.5, 0.5)
Logo.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
Logo.BackgroundTransparency = 1.000
Logo.Position = UDim2.new(0.499609053, 0, 0.498555, 0)
Logo.Size = UDim2.new(0, 184, 0, 159)
Logo.Image = "rbxassetid://5792442170"
Ring.Name = "Ring"
Ring.Parent = Frame
Ring.AnchorPoint = Vector2.new(0.5, 0.5)
Ring.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
Ring.BackgroundTransparency = 1.000
Ring.Position = UDim2.new(0.499609053, 0, 0.498555, 0)
Ring.Size = UDim2.new(0, 184, 0, 159)
Ring.Image = "rbxassetid://5792464702"
Welcome.Name = "Welcome"
Welcome.Parent = Frame
Welcome.AnchorPoint = Vector2.new(0.5,0.5)
Welcome.BackgroundTransparency = 1
Welcome.Position = UDim2.new(0.499609053, 0, 0.75, -25)
Welcome.Text = "Now Loading."
Welcome.TextColor3 = Color3.fromRGB(56, 62, 67)
Welcome.TextSize = 32
Welcome.Font = Enum.Font.ArialBold
Loading.Parent = playerGui
Loading.IgnoreGuiInset = true
ReplicatedFirst:RemoveDefaultLoadingScreen()
local tweenInfo = TweenInfo.new(
1.75, -- The time the tween takes to complete
Enum.EasingStyle.Quint, -- The tween style.
Enum.EasingDirection.Out, -- EasingDirection
-1, -- How many times you want the tween to repeat. If you make it less than 0 it will repeat forever.
false, -- Reverse?
0 -- Delay
)
local TweenService = game:GetService("TweenService")
local tween = TweenService:Create(Ring, tweenInfo, { Rotation=360 })
tween:Play()
tips = {
"Remember! Licking doornobs is illegal on other planets.",
"Hungry? Head to the cafeteria to grab some delicious 'pizza'!",
"Want a break? Head to our relaxation facility!"
}
changeEnabled = true
function changeText()
while changeEnabled do
Welcome.Text = tips[math.random(1, #tips)]
wait(5)
end
coroutine.yield()
end
local textChangeCoRoutine = coroutine.wrap(changeText)
textChangeCoRoutine()
if not game:IsLoaded() then
game.Loaded:Wait()
end
print("Game Loaded!")
Welcome.Text = "Loaded!"
changeEnabled = false
wait(6)
function callback()
Loading:Destroy() -- Remove the loader so it doesn't lag the game.
script:Destroy() -- Just to be safe :)
end
Frame:TweenPosition(UDim2.new(0,0,1,0), Enum.EasingDirection.Out, Enum.EasingStyle.Quad, 1, false)
wait(5)
callback()
How can I fix this, if I even can?
Thanks!