Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do i make it so when you hover over a frame its color changes smoothly?

Ok so i have tried multiple examples, they didn't work i want it so it's like:

script.Parent.Frame.MouseEnter:Connect(function()
    Frame.BackgroundColor3 = Color3.new() -- whatever scripts here
end)

then the rest.

1 comment

0

On the second line you have just written Frame , are you sure it shouldn't be script.Parent.Frame ?

2 answers

✓ Accepted answer

Hello! The answer you are looking for is TweenService.

local TweenService = game:GetService("TweenService")
local TweenInformation = TweenInfo.new(
	0.75, -- How many seconds does it take to finish the tween.
	Enum.EasingStyle.Linear, -- EasingStyle.
	Enum.EasingDirection.InOut, -- EasingDirection.
	0, -- How many times will it repeat,
	false, -- If set to true, it will return to the default properties when the tween is finished.
	0 -- The delay between each tween.
)

script.Parent.Frame.MouseEnter:Connect(function()
	TweenService:Create(script.Parent.Frame, TweenInformation, {BackgroundColor3 = Color3.fromRGB(70,70,70)}):Play()
	-- Syntax: TweenService:Create(Object, TweenInforamtion, Properties to Change)
end)

script.Parent.Frame.MouseLeave:Connect(function()
	TweenService:Create(script.Parent.Frame, TweenInformation, {BackgroundColor3 = Color3.fromRGB(255, 255, 255)}):Play()
end)

-- Note: If you want to use a BrickColor as Color3 do: BrickColor.new("Bright orange").Color
-- Don't forget to :Play() any tween you create.

What your trying to go for is to when the mouse enters and leaves a frame to cause the 'look' your going for. Eg; https://gyazo.com/5ceac893bc0c4cf61d3925428e1521e3

What you missing is that when you MouseLeave, this detects when the mouse leaves the parameters of the frame.

The code for the above gyazo looks something like this:

script.Parent.Frame.MouseEnter:Connect(function()
script.Parent.Frame.BackgroundColor3 = Color3.fromRGB(200,200,200)
end)

script.Parent.Frame.MouseLeave:Connect(function()
script.Parent.Frame.BackgroundColor3 = Color3.fromRGB(255,255,255)
end)

As you can see, its simply changing the colour to a darker colour and then upon the mouseleaving it reverts to its old colour

Hopefully I could help.

4 comments

0

Well.. The color changes Instantly i wanted it to be smoothly could you do that?

0

What should i do with the MouseLeave() With the GUI One?

0

Same but using reversing it.

This discussion is preserved as it was. New answers, comments, and votes are closed.