Mouse did not hovering button with UI Gradient

I scripted the mouse to hover a button with UIGradient that appears, but it says is unable to cast to dictionary. But there is a script below:

local tweenInfoHover = TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)

local csHover = ColorSequence.new{
	ColorSequenceKeypoint.new(0, Color3.new(0, 0.682353, 1)),
	ColorSequenceKeypoint.new(1, Color3.new(0, 0.301961, 0.443137))
}

local csLeave = ColorSequence.new{
	ColorSequenceKeypoint.new(0, Color3.new(0, 0, 0)),
	ColorSequenceKeypoint.new(1, Color3.new(0, 0, 0))
}

toggleMenu.MouseEnter:Connect(function()
	tweenService:Create(toggleMenu.UIGradient.Color, tweenInfoHover, csHover)
end)

toggleMenu.MouseLeave:Connect(function()
	tweenService:Create(toggleMenu.UIGradient.Color, tweenInfoHover, csLeave)
end)

How do I create a mouse hovering button like UIGradient?

The first parameter of TweenService requires an Instance, you’re attempting to tween a property of said “Instance” which results back as that error

Make sure to make your first & third parameters correct so that the Tween can properly play:

local tweenInfoHover = TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)

local csHover = ColorSequence.new{
	ColorSequenceKeypoint.new(0, Color3.new(0, 0.682353, 1)),
	ColorSequenceKeypoint.new(1, Color3.new(0, 0.301961, 0.443137))
}

local csLeave = ColorSequence.new{
	ColorSequenceKeypoint.new(0, Color3.new(0, 0, 0)),
	ColorSequenceKeypoint.new(1, Color3.new(0, 0, 0))
}

toggleMenu.MouseEnter:Connect(function()
	tweenService:Create(toggleMenu.UIGradient, tweenInfoHover, {Color = csHover})
end)

toggleMenu.MouseLeave:Connect(function()
	tweenService:Create(toggleMenu.UIGradient, tweenInfoHover, {Color = csLeave})
end)

It sounds so good, thanks for the help! So, I’ll try if is working.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.