Waiting until game is loaded

Hi! Im currently trying to make a start screen for my game and it seems like the script starts until the player is actually loaded… I might be incorrect but that seems like how it is. Ive looked on scriptinghelpers and found nothing.

local TS = game:GetService('TweenService')
local part = game.Workspace:WaitForChild("Camera1")
local Camera = workspace.CurrentCamera

repeat wait() until game.Players.LocalPlayer.Character 

local goal = {Position = Vector3.new(216.047, 10.922, 18.328)}
local tween = TweenInfo.new(40, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, -1, true, 0)
local tweened = TS:Create(part, tween, goal)
tweened:Play()
Camera.CameraType = Enum.CameraType.Scriptable
Camera.CFrame = part.CFrame
Camera.CameraSubject = part
game.Players.LocalPlayer.CameraMode = Enum.CameraMode.LockFirstPerson
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.All, false)
1 Like

You can use the game:IsLoaded() function to detect if the game loaded. Just wrap it into a repeat until.

3 Likes

By the title I understand that you want the screen to load until the game is loaded, you can simply do

repeat wait() until game:IsLoaded()
5 Likes

Thanks! I’ll try it out. characterss

1 Like
local TS = game:GetService('TweenService')
local part = game.Workspace:WaitForChild("Camera1")
local Camera = workspace.CurrentCamera

repeat wait() until game:IsLoaded()

local goal = {Position = Vector3.new(216.047, 10.922, 18.328)}
local tween = TweenInfo.new(40, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, -1, true, 0)
local tweened = TS:Create(part, tween, goal)
tweened:Play()
Camera.CameraType = Enum.CameraType.Scriptable
Camera.CFrame = part.CFrame
Camera.CameraSubject = part
game.Players.LocalPlayer.CameraMode = Enum.CameraMode.LockFirstPerson
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.All, false)

Tried it. I got no result. @WooleyWool

1 Like
2 Likes

I think you want to wait until everything is loaded, right? You can achieve this by using ContentProvider:PreloadAsync. Just loop this trough every object in your game in a pcall.

6 Likes

I usually just wait for the game.Loaded event to be fired:

game.Loaded:Wait()
-- stuff
19 Likes