How do I tween an entire GUI's everything (themes)

ok so this relates to my last post, now that I got a theme system that changes themes, how do I tween it so it changes more smoothly?

I know I could try just tweening the background color, but then the text color will be ignored. if I add in a text color, I’ll have to add a check to make sure that the thing is a text button or label. then I would have to do a check for if it’s tweening just the text, just the background, or both. and finally, what if I decide I want to change font, font size, rotation, etc? right now it’s easy and it can do all that, but if I add in tweening it gets a lot more difficult, and so far it only results in an error. this is the code I have to help try to understand what I’m doing and how I’m doing it to get more effective help.

--script written by IVoidstarI, edited by rankydoodle

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")

local player = Players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")

local themes = ReplicatedStorage.Themes
local theme = script.Theme.Value

local uiOverrides = theme.UIOverrides
local uiColors = theme.Colors

local currentTheme
local currentGui

local function ApplyTheme(currentTheme : Folder, currentGui : GuiObject)	
	for _, child in pairs(currentTheme:GetChildren()) do
		if child:IsA("Folder") then
			ApplyTheme(child, currentGui[child.Name])
		elseif child:IsA("ValueBase") then
			local colorName = child.Value
			local colorValue = uiColors[colorName].Value

			currentGui[child.Name] = colorValue
	for i, v in pairs(playerGui:GetChildren()) do
		if v.Name == "Colors" then
			--print("Colors Folder Found, Destroying")
	local CuiColors = uiColors:Clone()
	CuiColors.Parent = playerGui

ApplyTheme(uiOverrides, playerGui)

	--print("Theme Change!")
	theme = script.Theme.Value
	uiOverrides = theme.UIOverrides
	uiColors = theme.Colors
	ApplyTheme(uiOverrides, playerGui)

if I try to do something like

TweenService:Create(currentGui, TweenFunction, {currentGui[child.Name] = colorValue}):Play()

within the part that applies the theme it gives me an error stating “unable to cast to dictionary.” is there anything that I can try?

1 Like

currentGui[child.Name] is getting the value of the property.

If child.Name is the property that we’re changing, and colorValue is what the property’s value will slowly progress to at the end, we can map our propertyTable argument out like this:

 {[child.Name] = colorValue}

Try this instead.
I assume you already have TweenInfo to work with, just replace as is.

local tweenInfo =, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
TweenService:Create(currentGui, tweenInfo, {[child.Name] = colorValue}):Play()