Hello there, I’m trying to create a effect where when your mouse hovers over a button a frame on the button tweens forward and when your mouse leaves the button the frame tweens back.
I have a idea on how I’d create it but I thought MouseLeave was inconsistent and not firing every time the mouse leaves a button, I’m not sure on how to do this as any help would be appreciated. Thanks
What exactly do you mean by it tweening forward? If it tweens out of the way so that the mouse is already no longer on the button, it would just tween back almost immediately.
script.Parent.MouseEnter:Connect(function()
local info = TweenInfo.new(0.5)
local tween = game:GetService(“TweenService”):Create(script.Parent,info,{BackgroundColor3=Color3.fromRGB(255, 255, 255)})
tween:Play()
end)
script.Parent.MouseLeave:Connect(function()
local info = TweenInfo.new(0.5)
local tween = game:GetService(“TweenService”):Create(script.Parent,info,{BackgroundColor3=Color3.fromRGB(62, 63, 77)})
tween:Play()
end)
Put your button within a frame, Frame should be sized like a button.
The frame, should have clip descendants on as well to make sure that
the line doesn’t move outside of the frame itself if it happens.
Inside the button should be 1,0,1,0 (So the button fits the whole entire frame.)
Highlight UI
Highlight, having an Anchor point of (0,0.5), So that it is able to come out of the left.
Highlight positioned at (0,0,0.5,0).
Highlight being sized at (0,0,1,0)
Now you should have this:
Line shouldn’t be visible since its small.
Now you can tween it with whatever type of style you want, If you need a script
provided you can reply to this.
It’s a separate textlabel with position and size set to the absolute position and size of the normal textlabel inside the button, parented to the blue frame