Advertisement
Guest User

Roblox: Preload Assets Screen

a guest
Feb 16th, 2020
317
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. game:GetService("ReplicatedFirst"):RemoveDefaultLoadingScreen() -- removes the default loading screen
  2. local cp = game:GetService("ContentProvider") -- gets the content provider
  3.  
  4. -- config
  5. local optionalAssets = {} -- optional assets to loads, ex (555, 555)
  6. local disabledService = {
  7. ["Lighting"] = false;
  8.  
  9. } -- services no so preload
  10.  
  11.  
  12. local ui = script:WaitForChild("loadingUI")
  13. ui.Parent = game:GetService("Players").LocalPlayer:WaitForChild("PlayerGui")
  14. local blur = Instance.new("BlurEffect", game:GetService("Workspace").CurrentCamera)
  15.  
  16. -- preloading
  17. warn("starting preload")
  18. local startTick = tick()
  19. -- preload the optional assets first
  20. cp:PreloadAsync(optionalAssets)
  21.  
  22. -- preload the entire game
  23. for i,service in pairs(game:GetChildren()) do
  24. pcall (function()
  25. if not disabledServices[service.Name] then
  26. --warn("service not available")
  27. cp:PreloadAsync({service})
  28. end
  29. end)
  30. end
  31. wait(15)
  32. warn("preload done, time: "..string.sub(tick()-startTick, 1, 5).."s")
  33. ui:Remove()
  34. blur:Remove()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement