I just added a dark/light mode script to my gui, the problem is that it doesnt fully work, it only turns some of the stuff to the next mode, the rest stays normal.
local TweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(.3, Enum.EasingStyle.Exponential, Enum.EasingDirection.Out)
local gui = script.Parent
local mainFrame = gui:WaitForChild("MainFrame")
local resultsFrame = mainFrame:WaitForChild("ResultsFrame")
local noresultsLabel = resultsFrame:WaitForChild("NoResultsLabel")
local searchFrame = mainFrame:WaitForChild("SearchFrame")
local bottomBar = searchFrame:WaitForChild("BottomBar")
local search = bottomBar:WaitForChild("Search")
local textBox = search:WaitForChild("TextBox")
local results = {}
local modes = {
["DarkMode"] = {
BG_Color1 = Color3.fromRGB(24, 25, 26),
BG_Color2 = Color3.fromRGB(57, 61, 62),
Text_Color1 = Color3.fromRGB(255, 255, 255),
Text_Color2 = Color3.fromRGB(200, 200, 200),
PlaceholderColor = Color3.fromRGB(178, 178, 178),
PlaceholderTextColor = Color3.fromRGB(232, 235, 235),
ImageColor = Color3.fromRGB(255, 255, 255),
StrokeTransparency = .4
},
["LightMode"] = {
BG_Color1 = Color3.fromRGB(209, 213, 217),
BG_Color2 = Color3.fromRGB(160, 168, 177),
Text_Color1 = Color3.fromRGB(54, 58, 65),
Text_Color2 = Color3.fromRGB(77, 80, 87),
PlaceholderColor = Color3.fromRGB(89, 89, 89),
PlaceholderTextColor = Color3.fromRGB(54, 58, 65),
ImageColor = Color3.fromRGB(54, 58, 65),
StrokeTransparency = .95
}
}
local currentMode = modes.DarkMode
local function switchMode(mode)
if mode == currentMode then return end
local oldMode = currentMode
local newMode = mode
for _, v in pairs(mainFrame:GetDescendants()) do
if v:IsA("Frame") then
if v.BackgroundColor3 == oldMode.BG_Color1 then
v.BackgroundColor3 = newMode.BG_Color1
elseif v.BackgroundColor3 == oldMode.BG_Color2 then
v.BackgroundColor3 = newMode.BG_Color2
end
elseif v:IsA("TextButton") then
if v.BackgroundColor3 == oldMode.BG_Color1 then
v.BackgroundColor3 = newMode.BG_Color1
end
elseif v:IsA("TextLabel") then
if v.TextColor3 == oldMode.Text_Color1 then
v.TextColor3 = newMode.Text_Color1
elseif v.TextColor3 == oldMode.Text_Color2 then
v.TextColor3 = newMode.Text_Color2
end
elseif v:IsA("TextBox") then
if v.PlaceholderColor3 == oldMode.PlaceholderColor then
v.PlaceholderColor3 = newMode.PlaceholderColor
end
if v.TextColor3 == oldMode.PlaceholderTextColor then
v.TextColor3 = newMode.PlaceholderTextColor
end
elseif v:IsA("ImageLabel") then
if v.ImageColor3 == oldMode.ImageColor then
v.ImageColor3 = newMode.ImageColor
end
elseif v:IsA("UIStroke") then
if v.Transparency == oldMode.StrokeTransparency then
v.Transparency = newMode.StrokeTransparency
end
end
end
currentMode = newMode
end
textBox:GetPropertyChangedSignal("Text"):Connect(function()
results = {}
local bareText = textBox.Text
local searchText = bareText:lower()
local resultFound = false
for _, result in pairs(resultsFrame:GetChildren()) do
if result:IsA("TextButton") then
local isMatch = (searchText == "" or result.Name:lower():find(searchText) ~= nil)
result.Visible = isMatch
if isMatch then
table.insert(results, result.Name)
resultFound = true
end
end
end
local emptyText = bareText == ""
if emptyText then
resultsFrame.Visible = false
noresultsLabel.Visible = false
else
resultsFrame.Visible = true
noresultsLabel.Visible = true
noresultsLabel.Text = [[<b>]]..#results..[[</b> results found for "<b>]]..tostring(bareText)..[[</b>"]]
end
print("Result Found:", resultFound)
end)
local function hoverAnimation()
for _, button in pairs(resultsFrame:GetChildren()) do
if button:IsA("TextButton") then
button.MouseEnter:Connect(function()
TweenService:Create(button, tweenInfo, {BackgroundTransparency = .2}):Play()
end)
button.MouseButton1Down:Connect(function()
TweenService:Create(button, tweenInfo, {BackgroundTransparency = .5}):Play()
end)
button.InputEnded:Connect(function()
TweenService:Create(button, tweenInfo, {BackgroundTransparency = 1}):Play()
end)
end
end
end
hoverAnimation()
local modeFrame = gui:WaitForChild("ModeFrame")
local darkButton = modeFrame:WaitForChild("DarkMode")
local lightButton = modeFrame:WaitForChild("LightMode")
darkButton.Activated:Connect(function()
switchMode(modes.DarkMode)
end)
lightButton.Activated:Connect(function()
switchMode(modes.LightMode)
end)
Heres both of the modes (light not completely right):
heres what it looks like:
As you can see, it only changes some of the stuff to the correct color, and it’s the same stuff every time.
If you can help me i’d really appreciate it, thanks.