Just letting you know incase this matters, the scripts parent is a ScreenGui, this ScreenGui’s parent is StarterGui. Also it loads properly if the if not game:IsLoaded() returns true. It’s only if the game hasn’t loaded yet where the issue arises.
Here is the rest of the code prior to the game:IsLoaded():
local ReplicatedFirst = game:GetService("ReplicatedFirst")
local loadingFrame = script.Parent:WaitForChild('loadingFrame')
local menuFrame = loadingFrame.Parent:FindFirstChild('menu')
local blankFrame = menuFrame.Parent.blankFrame
local tweenService = game:GetService('TweenService')
local rn = game:GetService('RunService')
local CP = game:GetService('ContentProvider')
local event = game.ReplicatedStorage:WaitForChild('Events'):WaitForChild('loaded')
local buttons = menuFrame:FindFirstChild('Buttons')
local started = false
loadingFrame.Visible = true
menuFrame.Visible = true
ReplicatedFirst:RemoveDefaultLoadingScreen()
if not game:IsLoaded() then
game.Loaded:Wait()
end
print("Game has loaded") -- Doesn't print.
I think your game may have loaded before the if not game:IsLoaded(), because it works for me if it has but if it hasn’t then it just gets stuck at game.Loaded:Wait.
local ReplicatedFirst = game:GetService("ReplicatedFirst")
local loadingFrame = script.Parent:WaitForChild('loadingFrame')
local menuFrame = loadingFrame.Parent:FindFirstChild('menu')
local blankFrame = menuFrame.Parent.blankFrame
local tweenService = game:GetService('TweenService')
local rn = game:GetService('RunService')
local event = game.ReplicatedStorage:WaitForChild('Events'):WaitForChild('loaded')
local buttons = menuFrame:FindFirstChild('Buttons')
local started = false
loadingFrame.Visible = true
menuFrame.Visible = true
ReplicatedFirst:RemoveDefaultLoadingScreen()
event.Event:Wait()
local startScreenFold = workspace:WaitForChild('startScreen')
local mainCam = startScreenFold.mainCam
task.wait(1)
local goals = {
["Ani1"] = {mainCam.CFrame, startScreenFold.goalOne.CFrame};
["Ani2"] = {startScreenFold.goalTwoStart.CFrame, startScreenFold.goalTwoEnd.CFrame};
["Ani3"] = {startScreenFold.goalThreeStart.CFrame, startScreenFold.goalThreeEnd.CFrame};
}
print('starting')
local function setVisible()
for i, v in pairs(loadingFrame:GetChildren()) do
for i = 1,20 do
loadingFrame.Transparency += 0.05
v.Transparency += 0.05
task.wait()
end
loadingFrame:Destroy()
task.wait(1)
end
end
local function tween(goal, dur)
print('tweening')
local info = TweenInfo.new(
dur,
Enum.EasingStyle.Linear,
Enum.EasingDirection.Out,
0,
false
)
local goal = {
CFrame = goal
}
local tween = tweenService:Create(mainCam, info, goal)
tween:Play()
tween.Completed:Wait()
end
task.wait(2)
spawn(setVisible)
local cam = workspace.Camera
cam.CameraType = Enum.CameraType.Scriptable
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
char.Humanoid.WalkSpeed = 0
coroutine.wrap(function()
while started == false do
local speed = 5
for i, v in pairs(goals) do
print('setting')
mainCam.CFrame = v[1]
print('set')
tween(v[2], speed)
end
task.wait()
end
task.wait()
end)()
local connection = rn.RenderStepped:Connect(function()
cam.CFrame = mainCam.CFrame
end)
buttons.playButton.MouseButton1Up:Connect(function()
for i = 1,20 do
blankFrame.Transparency -= 0.05
task.wait(0.05)
end
task.wait(1)
char.Humanoid.WalkSpeed = 16
started = true
cam.CameraType = Enum.CameraType.Custom
connection:Disconnect()
menuFrame:Destroy()
for i = 1,20 do
blankFrame.Transparency += 0.05
task.wait(0.05)
end
script.Parent:Destroy()
end)
I was about to mention that lol, I’m trying to see if putting a script in replicated first, then waiting for it to load, and then firing an event once it has, will fix it.