I’ve been trying to figure out how to tween GUI Colors for the past few days and shortened down to this script.
local GUI = script.Parent
local tweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(
1, -- time in seconds for tween
Enum.EasingStyle.Sine, -- tweening style
Enum.EasingDirection.Out, -- tweening direction
0, -- times to repeat (when less than zero the tween will loop indefinitely)
false, -- reverses
0 -- delay time
)
local IsEnabled = script.Parent.Parent.IsEnabled
local Colors = {
Color3.fromRGB(76, 255, 56);
Color3.fromRGB(255, 76, 79);
}
script.Parent.MouseButton1Click:Connect(function()
if IsEnabled == false then
local property = {Color = Colors[1]} -- property name and property value (be sure to place in table)
local tween = tweenService:Create(GUI, tweenInfo, property)
IsEnabled.Value = true
tween:Play() -- plays tween
else
local property = {BackgroundColor = Colors[2]} -- property name and property value (be sure to place in table)
local tween = tweenService:Create(GUI, tweenInfo, property)
IsEnabled.Value = false
tween:Play() -- plays tween
end
end)
-- red: 255, 76, 79
-- green: 76, 255, 56
The isEnabled is a BooleanValue I put in the GUI to track if the setting is off or on.
The current error I’m getting is this - TweenService:Create property named 'BackgroundColor' cannot be tweened due to type mismatch (property is a 'int', but given type is 'Color3')
.