-- Displays a hint to the player that the GUI auto-hides.
-- 
-- ForbiddenJ


IsGuiDisplayed = script.Parent.IsDisplayed
IsHiddenByOtherGUI = script.Parent.IsHiddenByOtherGUI
SpawnNotification = game.ReplicatedStorage.ClientStorage.SpawnNotification
SmallHint = script.Parent.SmallHint

HasShownLargeHint = false

function Update()
	SmallHint.Visible = not IsGuiDisplayed.Value
	
	if not HasShownLargeHint and not IsGuiDisplayed.Value and not IsHiddenByOtherGUI.Value then
		HasShownLargeHint = true
		
		local notification =
			SpawnNotification:Invoke("Hover mouse to show panel.", nil, -1)
		SmallHint.ImageTransparency = 0
		notification.TextStrokeColor3 = Color3.new(0.7, 0.7, 0.7)
		
		local tween = game.TweenService:Create(
			SmallHint,
			TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, math.huge),
		{ImageTransparency = 0.85})
		tween.Parent = SmallHint
		tween:Play()
		local tween2 = game.TweenService:Create(
			notification,
			TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, math.huge),
			{TextStrokeColor3 = Color3.new(0, 0, 0)})
		tween2.Parent = notification
		tween2:Play()
		
		local hintCleanedUp = false
		local function cleanupHint()
			if not hintCleanedUp then
				if notification.Parent ~= nil then
					notification.LifetimeLeft.Value = 0
				end
				tween:Cancel()
				tween:Destroy()
				SmallHint.ImageTransparency = 0.85
				
				hintCleanedUp = true
			end
		end
		
		delay(10, cleanupHint)
		IsGuiDisplayed.Changed:Wait()
		cleanupHint()
	end
end

IsGuiDisplayed.Changed:Connect(Update)

Update()
