Hello. I am having an issue when trying to tween a UI’s BackgroundColor3
when MouseEnter
and MouseLeave
events are fired. Here is my code:
local frame = script.Parent;
local tweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(
1
)
local goals = {
BackgroundColor3 = Color3.new(90, 0, 135)
}
local tween1 = tweenService:Create(frame, tweenInfo, goals)
local goals2 = {
BackgroundColor3 = Color3.new(170, 0, 255)
}
local tween2 = tweenService:Create(frame, tweenInfo, goals2)
local function on_Enter()
tween1:Play()
end
frame.MouseEnter:Connect(on_Enter)
local function on_Leave()
tween2:Play()
end
frame.MouseLeave:Connect(on_Leave)