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

How can i fade a color (imagecolor) gui?

2 answers

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.

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)

2 comments

0

It just turns green. it doesnt fade to white.

0

For Me It Worked, Did You Check For Errors Maybe You Used A Image Label Or Something Like That?

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