How do I add it so when the home button is pressed it returns to this loading screen?
Loading Screen Code:
local camera = workspace.CurrentCamera -- We're placing the player's camera as a variable.
local cameraCFrame = Vector3.new(172.86821, 11.4222488, 110.478027)
local cameraFocus = Vector3.new(174.728912, 10.9349756, 111.025864)
local introUI = script.Parent -- Defining the text objects
local playButton = introUI.PlayButton
local creditButton = introUI.CreditButton
local shopButton = introUI.ShopButton
local aboutButton = introUI.AboutButton
local TweenService = game:GetService("TweenService") -- This tween stuff will apply to scripting the play button!
local tweeningInfo = TweenInfo.new(.25, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0)
local function hoverEffect(object) -- Make function for it to move a bit.
local originalPosition = object.Position
object.MouseEnter:Connect(function()
object:TweenPosition((originalPosition + UDim2.new(.015, 0, 0, 0)), "Out", "Sine", .1, true)
end)
object.MouseLeave:Connect(function()
object:TweenPosition((originalPosition), "Out", "Sine", .1, true)
end)
end
-- This part helps apply the hover effect scripted onto the button!
hoverEffect(playButton)
hoverEffect(creditButton)
hoverEffect(shopButton)
hoverEffect(aboutButton)
--Time to script the play portion!
playButton.MouseButton1Click:Connect(function()
local fading = introUI.FadeScreen --This is my frame that was transparent.
local fadeTweenOpaque = TweenService:Create(fading, tweeningInfo, {BackgroundTransparency = 0})
local fadeTweenTransparent = TweenService:Create(fading, tweeningInfo, {BackgroundTransparency = 1})
fadeTweenOpaque :Play()
wait(.75) -- Abitrary number, change to what you wish.
camera.CameraType = Enum.CameraType.Custom -- Change the camera back to player control.
for _, object in pairs(introUI:GetChildren()) do
if object ~= fading then
object:Destroy()
end
end
fadeTweenTransparent:Play()
end)
workspace:WaitForChild(tostring(camera)) -- Our camera stuff from before
wait(.1)
camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = CFrame.new(cameraCFrame, cameraFocus)
Home button code:
local playButton = script.Parent.TopFrame.home
local shopButton = script.Parent.TopFrame.store
local TweenService = game:GetService("TweenService") -- This tween stuff will apply to scripting the play button!
local tweeningInfo = TweenInfo.new(.25, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0)
local function hoverEffect(object) -- Make function for it to move a bit.
local originalPosition = object.Position
object.MouseEnter:Connect(function()
object:TweenPosition((originalPosition + UDim2.new(.015, 0, 0, 0)), "Out", "Sine", .1, true)
end)
object.MouseLeave:Connect(function()
object:TweenPosition((originalPosition), "Out", "Sine", .1, true)
end)
end
hoverEffect(playButton)
hoverEffect(shopButton)
local creditButton = script.Parent.home
local creditTab = script.IntroUI2
local creditOpened = false
creditButton.MouseButton1Click:Connect(function()
creditOpened = not creditOpened
creditTab.Visible = creditOpened
end)