Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can i fade a color (imagecolor) gui?

Asked by
i9deo 2
3 years ago

The color i'm wanting to fade is green to white (On click it turns green then i want it to fade to white.)

2 answers

Log in to vote
0
Answered by
Raccoonyz 1092 Donator Moderation Voter
3 years ago

TweenService is what you need.

And since I'm in a good mood, I'll break down an example.

-- Assumes that the script is a localscript and is in the GuiButton
local TweenService = game:GetService("TweenService") -- Define the TweenService service into a variable
local goal = {} -- It's best to not define the goal for every run
local info = TweenInfo.new(1) -- This sets the time to fade to one (1) second. 
local tween = TweenService:Create(script.Parent, info, goal) -- Create the tween.
script.Parent.MouseButton1Click:Connect(function() -- Connect to the MouseButton1Click event of the GuiButton
    script.Parent.Color = Color3.fromRGB(0, 255, 0) -- Set the color to green
    tween:Play() -- Play the tween.
end) -- Tells the compiler that we are done defining the function. If you don't have this, you'll get a SyntaxError.

Ad
Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

local TweenService = game:GetService("TweenService") local goal = {ImageColor3 = Color3.fromRGB(255, 255, 255); } local info = TweenInfo.new(1) local tween = TweenService:Create(script.Parent, info, goal) script.Parent.MouseButton1Click:Connect(function() script.Parent.ImageColor3 = Color3.fromRGB(0, 255, 0) tween:Play() end)

0
It just turns green. it doesnt fade to white. i9deo 2 — 3y
0
For Me It Worked, Did You Check For Errors Maybe You Used A Image Label Or Something Like That? andyc889 0 — 3y

Answer this question