The Problem?
I want a tooltip to disappear when the mouse is not on a Gui Button.
The Bug:
*As you can see the Tooltip is appearing after my mouse left. Apparently, the Script is saying that if the Mouse is/was on the GUI Button show the Tooltip.
My Code:
--Variables
local Search_Bar_Background = game.Players.LocalPlayer.PlayerGui["Game UI"].HomeScreen.Background.Search["Search Bar Background"]
local Search_Bar = game.Players.LocalPlayer.PlayerGui["Game UI"].HomeScreen.Background.Search["Search Bar"]
local Search_Icon = game.Players.LocalPlayer.PlayerGui["Game UI"].HomeScreen.Background.Search["Search Icon"]
local Settings_Button = game.Players.LocalPlayer.PlayerGui["Game UI"].HomeScreen.Background.Search["Settings Button"]
--Search Bar Focused & Lost Focus Tweens
local TweenService = game:GetService("TweenService")
--Focused Tween Logic
--Search Bar Background Color Tween
local SBB_TweenColor = Color3.fromRGB(223, 223, 223)
local SBB_TweenInfo = TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)
local SBB_Tween = TweenService:Create(Search_Bar_Background, SBB_TweenInfo, {BackgroundColor3=SBB_TweenColor})
--Lost Focus Tween Logic
--Search Bar Background Color Tween
local SBB_TweenColor = Color3.fromRGB(232, 232, 232)
local SBB_TweenInfo = TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)
local SBB_Tween2 = TweenService:Create(Search_Bar_Background, SBB_TweenInfo, {BackgroundColor3=SBB_TweenColor})
--When Search Bar Focused Do
Search_Bar.Focused:Connect(function()
SBB_Tween:Play()
Search_Icon.ImageColor3 = Color3.fromRGB(184, 184, 184)
Settings_Button.ImageColor3 = Color3.fromRGB(184, 184, 184)
Search_Bar.PlaceholderColor3 = Color3.fromRGB(184, 184, 184)
end)
--When Search Bar Lost Focus Do
Search_Bar.FocusLost:Connect(function()
SBB_Tween2:Play()
Search_Icon.ImageColor3 = Color3.fromRGB(199, 199, 199)
Settings_Button.ImageColor3 = Color3.fromRGB(199, 199, 199)
Search_Bar.PlaceholderColor3 = Color3.fromRGB(199, 199, 199)
end)
--Settings Button Click Tween & Logic
--Variables
local Settings_Button_Click = game.Players.LocalPlayer.PlayerGui["Game UI"].HomeScreen.Background.Search["Settings Button Click"]
local Settings_Button_ToolTip = game.Players.LocalPlayer.PlayerGui["Game UI"].HomeScreen.Background.Search["Settings Button"]["Settings Button ToolTip"]
--Settings Button Tween Logic
--Settings Button Hover Tween
local SBC_TweenInfo = TweenInfo.new(0.3, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)
local SBC_Tween = TweenService:Create(Settings_Button_Click, SBC_TweenInfo, {Transparency = 0.5})
--Settings Button Leave Tween
local SBC_TweenInfo = TweenInfo.new(0.3, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)
local SBC_Tween2 = TweenService:Create(Settings_Button_Click, SBC_TweenInfo, {Transparency = 1})
--Settings Button ToolTip Tween Enter
local ST_TweenInfo = TweenInfo.new(0.2, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)
local ST_Tween = TweenService:Create(Settings_Button_ToolTip, ST_TweenInfo, {BackgroundTransparency = 0.4})
--Settings Button ToolTip Tween Leave
local ST_TweenInfo = TweenInfo.new(0.2, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)
local ST_Tween2 = TweenService:Create(Settings_Button_ToolTip, ST_TweenInfo, {BackgroundTransparency = 1})
--If Mouse Enter Settings Button Do
Settings_Button.MouseEnter:Connect(function()
Settings_Button_Click.Visible = true
SBC_Tween:Play()
wait(1.5)
Settings_Button_ToolTip.Visible = true
ST_Tween:Play()
end)
--If Mouse Leave Settings Button Do
Settings_Button.MouseLeave:Connect(function()
SBC_Tween2:Play()
ST_Tween2:Play()
wait(0.3)
Settings_Button_ToolTip.Visible = false
Settings_Button_Click.Visible = false
end)