-- Local Functions

local function toggleNonTutorialGui(isEnabled)
	local PlayerGui = player.PlayerGui
	
	for _, child in ipairs(PlayerGui:GetChildren()) do
		if child:IsA("GuiObject") and child.Name ~= "Tutorial" then
			child.Enabled = isEnabled
		end
	end
end

local function startTutorial()
	toggleNonTutorialGui(false)
	
	Panels.Visible = true
	Panel1.Visible = true
	Panel2.Visible = false
end

local function nextPanel(input, gameProcessed)
	if Panel1.Visible == true then
		Panel1.Visible = false
		Panel2.Visible = true
		NextButton.ButtonLabel.Text = "GOT IT"
	elseif Panel2.Visible == true then
		Panel2.Visible = false
	
		-- Disable tutorial
		Panels.Visible = false
		
		-- Enable other gui
		toggleNonTutorialGui(true)
		
		if not IS_MOBILE then
			-- Show and tween arrow over move button until player earns
			-- 10 points
			Arrow.Visible = true
			local arrowThread = coroutine.create(
				function()
					local goal = totalPoints.Value + 10
					local startPos = Arrow.Position
			
					repeat
						Arrow:TweenPosition(UDim2.new(startPos.X.Scale, 0, startPos.Y.Scale, -20),
							Enum.EasingDirection.In, Enum.EasingStyle.Quad, 1, true)
						wait(1)
						Arrow:TweenPosition(UDim2.new(startPos.X.Scale, 0, startPos.Y.Scale, 0),
								Enum.EasingDirection.In, Enum.EasingStyle.Quad, 1, true)
						wait(1)
					until totalPoints.Value >= goal
	
					Arrow.Visible = false
				end)
			coroutine.resume(arrowThread)
		end
	end
end

