Hello, im not the best at scripting so bare with me.
Let's say there is 1 screengui in StarterGui, with 2 frames inside of it. 1 frame being the loading frame, then another frame being the Main Menu. I want the main menu too appear after someone dies, but not the loading screen so they dont have too wait for it too load again. I also followed a tutorial for this main menu + loading screen. The tutorial link is:
Main Handler Local Script- (Inside the ScreenGui)
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
char:WaitForChild("HumanoidRootPart").Anchored = true
local mouse = plr:GetMouse()
local camera = workspace.CurrentCamera
camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = workspace.MenuComponents.CameraStartPosition.CFrame
local tweenService = game:GetService("TweenService")
local mainMenuGui = script.Parent
local mainMenuBG = mainMenuGui:WaitForChild("MainMenuBackground")
local playBtn = mainMenuBG:WaitForChild("PlayButton")
local creditsBtn = mainMenuBG:WaitForChild("CreditsButton")
local creditsBG = mainMenuBG:WaitForChild("CreditsBackground")
local loadingScreenBG = mainMenuGui:WaitForChild("LoadingScreenBackground")
local logo = loadingScreenBG:WaitForChild("Logo")
local loadingBarBG = loadingScreenBG:WaitForChild("LoadingBarBG")
local clippingFrame = loadingBarBG:WaitForChild("ClippingFrame")
local loadingBar = clippingFrame:WaitForChild("LoadingBar")
clippingFrame.Size = UDim2.new(0, 0, 1, 0)
clippingFrame:TweenSize(UDim2.new(1, 0, 1, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quint, 5)
clippingFrame:GetPropertyChangedSignal("Size"):Connect(function()
loadingBar.Size = UDim2.new(1/clippingFrame.Size.X.Scale, 0, 1, 0)
end)
repeat wait() until clippingFrame.Size == UDim2.new(1, 0, 1, 0)
local loadingScreenFade = tweenService:Create(loadingScreenBG, TweenInfo.new(3, Enum.EasingStyle.Quint, Enum.EasingDirection.InOut), {BackgroundTransparency = 1})
loadingScreenFade:Play()
logo:TweenPosition(UDim2.new(0.5, 0, -0.5, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quint, 2)
loadingBarBG:TweenPosition(UDim2.new(0.5, 0, 1.5, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quint, 2)
local originalCFrame = camera.CFrame
local scaleFactor = 1000
game:GetService("RunService").RenderStepped:Connect(function()
local centreOfScreen = Vector2.new(camera.ViewportSize.X / 2, camera.ViewportSize.Y / 2)
local mouseDistanceFromCentre = Vector3.new((-mouse.X - centreOfScreen.X) / scaleFactor, (mouse.Y - centreOfScreen.Y) / scaleFactor, 0)
camera.CFrame = originalCFrame * CFrame.new(originalCFrame.LookVector + mouseDistanceFromCentre)
end)
local playButtonClicked = false
playBtn.MouseButton1Click:Connect(function()
if playButtonClicked then return end
playButtonClicked = true
creditsBG:TweenPosition(UDim2.new(-0.5, 0, 0.5, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quint, 1, true)
mainMenuBG:TweenPosition(UDim2.new(-1, 0, 0, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quint, 3, true)
wait(3)
char.HumanoidRootPart.Anchored = false
game.Players.LocalPlayer.PlayerGui.SelectionGui.Enabled = true
--char.HumanoidRootPart.CFrame = workspace.MenuComponents.SpawnPart.CFrame
mainMenuGui.Enabled = false
script.Disabled = true
end)
local creditsOpen = false
creditsBtn.MouseButton1Click:Connect(function()
if playButtonClicked then return end
if creditsOpen then
creditsBG:TweenPosition(UDim2.new(-0.5, 0, 0.5, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quint, 1, true)
else
creditsBG:TweenPosition(UDim2.new(0.5, 0, 0.5, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Quint, 1, true)
end
creditsOpen = not creditsOpen
end)
local function hoverOnButton(btn)
if playButtonClicked then return end
local colourDarken = tweenService:Create(btn, TweenInfo.new(0.1, Enum.EasingStyle.Quint, Enum.EasingDirection.InOut), {ImageColor3 = Color3.fromRGB(221, 221, 221)})
colourDarken:Play()
end
local function hoverOffButton(btn)
if playButtonClicked then return end
local colourNormal = tweenService:Create(btn, TweenInfo.new(0.1, Enum.EasingStyle.Quint, Enum.EasingDirection.InOut), {ImageColor3 = Color3.fromRGB(255, 255, 255)})
colourNormal:Play()
end
playBtn.MouseEnter:Connect(function()
hoverOnButton(playBtn)
end)
creditsBtn.MouseEnter:Connect(function()
hoverOnButton(creditsBtn)
end)
playBtn.MouseLeave:Connect(function()
hoverOffButton(playBtn)
end)
creditsBtn.MouseLeave:Connect(function()
hoverOffButton(creditsBtn)
end)

2 comments
I updated my code by removing a line that disabled the script. If that doesn't work, then I am unable to help. The code is poorly structured and would require extensive effort. What you could do is make the loading screen and main menu separate screen GUIs and change the loading screen menu screen gui property "ResetOnSpawn" to false.
Alright, thank you so much for your time. I'll be sure to do that.