Well Im happy with how my effects turned out however theres issues to address:
- When the buttons are close to eachother and i move my mouse very fast from one button to another the mouseLeave function does not work properly. Im not sure if Im just bad at scripting or if this is an engine bug.
Ive tried to fix this by adding a task.Spawn() while task.Wait(.1) do loop with a mouseIn bool value but it still doesnt work very smoothly. Ive seen other games fix this and I dont know how
Script:
for i, button in pairs(Buttons) do
local ButtonHoverTransparencyInfo = TweenInfo.new(0.2, Enum.EasingStyle.Sine)
local ButtonHoverTransparencyGoal = {BackgroundTransparency = 0.1}
local ButtonHoverTransparencyTween = TweenService:Create(button, ButtonHoverTransparencyInfo, ButtonHoverTransparencyGoal)
local ButtonHoverTransparencyGoal2 = {BackgroundTransparency = 0.5}
local ButtonHoverTransparencyTween2 = TweenService:Create(button, ButtonHoverTransparencyInfo, ButtonHoverTransparencyGoal2)
task.spawn(function()
while task.wait(0.1) do
if MouseIn == false then
ButtonHoverTransparencyTween2:Play()
button:TweenSize(UDim2.new(0.081, 0,0.164, 0),Enum.EasingDirection.In, Enum.EasingStyle.Sine , .2, false)
end
end
end)
button.MouseEnter:Connect(function()
SoundsFolder.Effects.Hover:Play()
MouseIn = true
ButtonHoverTransparencyTween:Play()
button:TweenSize(UDim2.new(0.09, 0,0.196, 0),Enum.EasingDirection.In, Enum.EasingStyle.Sine , .1, false)
end)
button.MouseLeave:Connect(function()
MouseIn = false
local ButtonHoverTransparencyInfo = TweenInfo.new(0.1, Enum.EasingStyle.Sine)
local ButtonHoverTransparencyGoal = {BackgroundTransparency = 0.1}
local ButtonHoverTransparencyTween = TweenService:Create(button, ButtonHoverTransparencyInfo, ButtonHoverTransparencyGoal)
ButtonHoverTransparencyTween:Play()
button:TweenSize(UDim2.new(0.081, 0,0.164, 0),Enum.EasingDirection.In, Enum.EasingStyle.Sine , .1, false)
ButtonHoverTransparencyTween2:Play()
end)
button.MouseButton1Click:Connect(function()
SoundsFolder.Effects.Click:Play()
end)
end