TweenService Not Working?

Code:

local TS = game:GetService("TweenService")

local Home = script.Parent.Home
local Username = Home.Username

local U_FOUTTween = TS:Create(Username, TweenInfo.new(1.5), {BackgroundColor3 = Color3.new(24, 24, 24)})
local U_FINTween = TS:Create(Username, TweenInfo.new(1.5), {BackgroundColor3 = Color3.new(48, 48, 48)})

Username.MouseEnter:Connect(function()
	print("U Entered")
	U_FOUTTween:Cancel()
	U_FINTween:Play()
end)

Output:
image

Explorer:
image

Game:
I hover over the “Username” textbox, the script prints “U Entered”, and the background color doesn’t tween but rather instantly turns to the end color.

What’s wrong?

This happened to me once before — the problem was that TweenService wasn’t working for things inside frames.

For starters could you explain why exactly you are cancelling a tween that isn’t playing?

Solution Found: Color3.new defaulted to HSV instead of RGB so that’s why it wasn’t working properly.

How You Can Solve Your Problem: Use Color3.fromRGB() instead of Color3.new() when using RGB values.

1 Like

It’s there in case the player fires MouseLeave before the tween on MouseEnter ends.

Maybe include in your solution that you used Color3.fromRGB instead of Color3.new to fix your problem since it could confuse other people reading your post.