How can i make a color of a image change over a second in a script from white to green smoothly?
You’ll want to use the TweenService. Here’s how I would do it:
local Part = workspace.Part
Part.Color = Color3.new(1, 1, 1)
local TS = game:GetService("TweenService")
local Info = TweenInfo.new(3, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, false, 0)
TS:Create(Part, Info, {Color = Color3.new(0, 1, 0)}):Play()
How can i do this with transparency as well?
Yup, just add more properties to the tween you create
TS:Create(Part, Info, {
Color = Color3.new(0, 1, 0),
Transparency = 1,
Size = Vector3.new(2, 7, 4),
Position = Vector3.new(10, 4, 10)
}):Play()
For me it wont change colors in my script is the problem that im using images and not parts?
Could you copy/paste here what you put in your script, please?
local Part = script.Parent
Part.BackgroundColor3 = Color3.new(255, 255, 255)
local TS = game:GetService("TweenService")
local Info = TweenInfo.new(3, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, false, 0)
local Beams = workspace.LLights
function onClick1()
script.Parent.mainloop1.Disabled = false
TS:Create(Part, Info, {BackgroundColor3 = Color3.new(0, 255, 0)}):Play()
end
script.Parent.BUTTON.MouseButton1Click:Connect(onClick1)
function onClick2()
script.Parent.mainloop1.Disabled = true
for X,B in pairs (Beams:GetChildren()) do
B.Motors.Pan.DesiredAngle = 0
B.Motors.Tilt.DesiredAngle = 0
end
end
script.Parent.MouseButton2Click:connect(onClick2)
function mousein ()
end
script.Parent.BUTTON.MouseEnter:Connect(mousein)
function mouseout ()
end
script.Parent.BUTTON.MouseLeave:Connect(mouseout)
Nothing stands out to me as a syntax issue yet. I assume script.Parent is a frame, or some sort of GUI element? Are you sure the BackroundTransparency is less than 1? Are there any errors in the console?
No errors that i can see lemme try again and see
I found the issue but how do i make it a bit faster
To make it faster, edit Info.
Here’s what each part of the TweenInfo variable does:
local Info = TweenInfo.new(A, B, C, D, E, F)
-- A: How LONG do you want this to last
-- B: Enum for the easing style
-- C: Enum for the easing direction (https://developer.roblox.com/en-us/api-reference/enum/EasingStyle)
-- D: How many times you want it to REPEAT
-- E: Do you want it to reverse once it reaches its end?
-- F: How long do you want it to DELAY before it starts?
How can i do multiple parts at once?
Unfortunately, you can’t change multiple things in one tween (at least as far as I know). You have to create multiple tweens for multiple objects.
Or use for i, v in pairs() do on a bunch of objects.
I’m a bit late to this, but before it changes to the color I want. It changes to many different colors before being the correct color.