#loading screen

1 messages · Page 1 of 1 (latest)

buoyant kestrel
#

i've been trying to optimize my loading screen for a while, but i kept on getting a lag spike when destroying it (or setting it's parent to nil)

#
local function fade_gui_out()
    leave.Active = false
    
    --LAGFGG GSPIKE END IT
    local clok = os.clock()
    for _, obj in gui:GetDescendants() do
        if obj:IsA("TextLabel") or obj:IsA("TextButton") then
            TweenService:Create(obj, tinfo, {TextTransparency = 1}):Play()
            
        elseif obj:IsA("ImageLabel") or obj:IsA("ImageButton") then
            TweenService:Create(obj, tinfo, {ImageTransparency = 1}):Play()
            
        elseif obj:IsA("Frame") then
            TweenService:Create(obj, tinfo, {BackgroundTransparency = 1}):Play()
            
        end
    end
    
    warn("1: ", tostring(os.clock() - clok))
    task.wait(tinfo_duration + 0.2)
    
    RunService.PostSimulation:Wait()
    gui.Enabled = false
    
    RunService.PostSimulation:Wait()
    gui.Parent = nil
    
    RunService.PostSimulation:Wait()
    gui:Destroy()
    
    print("ok u can stop")
end```
#

the code i sent is currently using runservice.postsimulation because i kept alternating between task.wait, runservice.prerender and other stuff i thought would help not spike it

#

commenting out both the .parent = nil line and the :destroy one will solve the spike

#

btw the for loop doesn't cause any spikes whatsoever and it isn't an external script causing this; the warn() printed 1: 0.00007920000643935055

solemn sedge
#

let me summarize this first

#

can you show me the loading screen UI so i can know more

buoyant kestrel
#

ya sure

#

screenshare? it's animated

buoyant kestrel
solemn sedge
#

am not too good at scripting and UI but let me summarize by using my stupad kid ahh brain

buoyant kestrel
#

actually no, i'll just record and crop the part where it spikes

solemn sedge
#

ok

buoyant kestrel
solemn sedge
#

hmmmm

#

what are you trying to fix btw

buoyant kestrel
#

wow

#

the lag spike

solemn sedge
#

oh yeah i forgot to see it :Skull:

#

hang on let me go seeing the issue (lag spike of the UI when clicking or the moving thing but let me see first)

#

oh i can see

#

the output

#

this might take a while to let me see the issue

tall geyser
#

make it a server script

solemn sedge
#

well so this kind of you need to use a CanvasGroup

#

you can control it the transparency for the entire group with group transparency

#

but if using a canvasgroup

#

its like uhh not really fixing the issue

#

you can put a local script inside the UI

#

if you cant use a canvsgroup

buoyant kestrel
#

you can control the transparency of the entire gui object using the canvas group instance?

loud trench
buoyant kestrel
#

but

#

i found out that it only spikes in studio

#

not in the actual game

solemn sedge
#

so thats the first good thing

#

but are you trying to fix the lag spike in studio and also the actual ame

dusty spear
#

it boosts performance by 100x

buoyant kestrel
#

and also i dont think the canvas group would work

#

for avoiding the getdescendants loop

solemn sedge
buoyant kestrel
#

holy shit

#

canvas group is revolutionary

#

ill use that instead of looping through the descendants

#

thank you very very very much

#

saved me 0.007s and prolly a lot of memory

solemn sedge
#

uh yeah i use that a lot in a lot of UIS

dawn badgeBOT
#

studio** You are now Level 6! **studio

solemn sedge
#

but i dont think it works for a loading screen

#

its the problem solved?

buoyant kestrel
#

yes

buoyant kestrel
wheat tangle
#

man microprofiler exists tho

#

and

#

s2?

buoyant kestrel
wheat tangle
buoyant kestrel
#

ive never had to use it

wheat tangle
#

wait why?

solemn sedge
#

not everyone use microprofiler

buoyant kestrel
#

and therefore didnt familiarize myself with it

#

i tried to

#

no spikes were showing up though

#

-# no spikes on ANY profiler service / thing

wheat tangle
#

have u tried benching it

#

see what takes too long

#

oh the problem is fixed

#

mb

buoyant kestrel
wheat tangle
#

;-;

solemn sedge
solemn sedge
buoyant kestrel
#

um

#

will this friendship benefit me

solemn sedge
#

idk man

#

why i have this in mind

rough totem
#

same thing happended to me

#

u get a lag spike

buoyant kestrel
#

i've just closed studio 'cause i need to go, i'll try it out tomorrow

#

thanks for the tip