Hello, I have a function that works when fired from one place, but not from the other.
Basically, in Script A, function ColorUI works fine, but in Script B, ColorUI does not change the UI color. I’m very confused as to why, because I get no errors, and I know the function executes because the print I added in sends in the dev console. Any help would be greatly apreciated.
Script A:
local RS = game:GetService("ReplicatedStorage")
local Folder = RS:WaitForChild("Misc")
local SetC = Folder:WaitForChild("SetColor")
local GrabC = Folder:WaitForChild("GrabColor")
local RedButton = script.Parent:WaitForChild("1Red")
local OrangeButton = script.Parent:WaitForChild("2Orange")
local YellowButton = script.Parent:WaitForChild("3Yellow")
local GreenButton = script.Parent:WaitForChild("4Green")
local LBlueButton = script.Parent:WaitForChild("5LightBlue")
local DBlueButton = script.Parent:WaitForChild("6DarkBlue")
local PurpleButton = script.Parent:WaitForChild("7Purple")
local PinkButton = script.Parent:WaitForChild("8Pink")
local WhiteButton = script.Parent:WaitForChild("9White")
local BlackButton = script.Parent:WaitForChild("99Black")
local MainUI = script.Parent.Parent.Parent.Parent
local Announcements = MainUI:WaitForChild("Announcements")
local CommandList = MainUI:WaitForChild("CommandList")
local Criminal = MainUI:WaitForChild("Criminal")
local MainOpen = MainUI:WaitForChild("MainOpen")
local Message = MainUI:WaitForChild("Message")
local ModMessage = MainUI:WaitForChild("ModMessage")
local SRT = MainUI:WaitForChild("SRT")
local TacticalArmor = MainUI:WaitForChild("TacticalArmor")
local UserLevel = MainUI:WaitForChild("UserLevel")
local UserS = MainUI:WaitForChild("UserSettings")
local function ColorUI(R, G, B)
Announcements.Title.BackgroundColor3 = Color3.fromRGB(R, G, B)
CommandList.TextLabel.BackgroundColor3 = Color3.fromRGB(R, G, B)
CommandList.Color.BackgroundColor3 = Color3.fromRGB(R, G, B)
Criminal.Title.BackgroundColor3 = Color3.fromRGB(R, G, B)
MainOpen.Menu.BackgroundColor3 = Color3.fromRGB(R, G, B)
MainOpen.Color.BackgroundColor3 = Color3.fromRGB(R, G, B)
MainOpen.RRT.Color.BackgroundColor3 = Color3.fromRGB(R, G, B)
ModMessage.TextLabel.BackgroundColor3 = Color3.fromRGB(R, G, B)
ModMessage.Color.BackgroundColor3 = Color3.fromRGB(R, G, B)
SRT.Title.BackgroundColor3 = Color3.fromRGB(R, G, B)
TacticalArmor.TextLabel.BackgroundColor3 = Color3.fromRGB(R, G, B)
UserLevel.TextLabel.BackgroundColor3 = Color3.fromRGB(R, G, B)
UserS.TextLabel.BackgroundColor3 = Color3.fromRGB(R, G, B)
UserS.Return.BackgroundColor3 = Color3.fromRGB(R, G, B)
end
local function ColorRed()
SetC:FireServer("Red")
RedButton.Choose.Visible = true
OrangeButton.Choose.Visible = false
YellowButton.Choose.Visible = false
GreenButton.Choose.Visible = false
LBlueButton.Choose.Visible = false
DBlueButton.Choose.Visible = false
PurpleButton.Choose.Visible = false
PinkButton.Choose.Visible = false
WhiteButton.Choose.Visible = false
BlackButton.Choose.Visible = false
ColorUI(255, 105, 84)
end
local function ColorOrange()
SetC:FireServer("Orange")
RedButton.Choose.Visible = false
OrangeButton.Choose.Visible = true
YellowButton.Choose.Visible = false
GreenButton.Choose.Visible = false
LBlueButton.Choose.Visible = false
DBlueButton.Choose.Visible = false
PurpleButton.Choose.Visible = false
PinkButton.Choose.Visible = false
WhiteButton.Choose.Visible = false
BlackButton.Choose.Visible = false
ColorUI(255, 170, 0)
end
local function ColorYellow()
SetC:FireServer("Yellow")
RedButton.Choose.Visible = false
OrangeButton.Choose.Visible = false
YellowButton.Choose.Visible = true
GreenButton.Choose.Visible = false
LBlueButton.Choose.Visible = false
DBlueButton.Choose.Visible = false
PurpleButton.Choose.Visible = false
PinkButton.Choose.Visible = false
WhiteButton.Choose.Visible = false
BlackButton.Choose.Visible = false
ColorUI(220, 222, 72)
end
local function ColorGreen()
SetC:FireServer("Green")
RedButton.Choose.Visible = false
OrangeButton.Choose.Visible = false
YellowButton.Choose.Visible = false
GreenButton.Choose.Visible = true
LBlueButton.Choose.Visible = false
DBlueButton.Choose.Visible = false
PurpleButton.Choose.Visible = false
PinkButton.Choose.Visible = false
WhiteButton.Choose.Visible = false
BlackButton.Choose.Visible = false
ColorUI(67, 153, 47)
end
local function ColorLBlue()
SetC:FireServer("LBlue")
RedButton.Choose.Visible = false
OrangeButton.Choose.Visible = false
YellowButton.Choose.Visible = false
GreenButton.Choose.Visible = false
LBlueButton.Choose.Visible = true
DBlueButton.Choose.Visible = false
PurpleButton.Choose.Visible = false
PinkButton.Choose.Visible = false
WhiteButton.Choose.Visible = false
BlackButton.Choose.Visible = false
ColorUI(71, 169, 234)
end
local function ColorDBlue()
SetC:FireServer("DBlue")
RedButton.Choose.Visible = false
OrangeButton.Choose.Visible = false
YellowButton.Choose.Visible = false
GreenButton.Choose.Visible = false
LBlueButton.Choose.Visible = false
DBlueButton.Choose.Visible = true
PurpleButton.Choose.Visible = false
PinkButton.Choose.Visible = false
WhiteButton.Choose.Visible = false
BlackButton.Choose.Visible = false
ColorUI(60, 77, 164)
end
local function ColorPurple()
SetC:FireServer("Purple")
RedButton.Choose.Visible = false
OrangeButton.Choose.Visible = false
YellowButton.Choose.Visible = false
GreenButton.Choose.Visible = false
LBlueButton.Choose.Visible = false
DBlueButton.Choose.Visible = false
PurpleButton.Choose.Visible = true
PinkButton.Choose.Visible = false
WhiteButton.Choose.Visible = false
BlackButton.Choose.Visible = false
ColorUI(144, 91, 178)
end
local function ColorPink()
SetC:FireServer("Pink")
RedButton.Choose.Visible = false
OrangeButton.Choose.Visible = false
YellowButton.Choose.Visible = false
GreenButton.Choose.Visible = false
LBlueButton.Choose.Visible = false
DBlueButton.Choose.Visible = false
PurpleButton.Choose.Visible = false
PinkButton.Choose.Visible = true
WhiteButton.Choose.Visible = false
BlackButton.Choose.Visible = false
ColorUI(214, 122, 215)
end
local function ColorWhite()
SetC:FireServer("White")
RedButton.Choose.Visible = false
OrangeButton.Choose.Visible = false
YellowButton.Choose.Visible = false
GreenButton.Choose.Visible = false
LBlueButton.Choose.Visible = false
DBlueButton.Choose.Visible = false
PurpleButton.Choose.Visible = false
PinkButton.Choose.Visible = false
WhiteButton.Choose.Visible = true
BlackButton.Choose.Visible = false
ColorUI(205, 205, 205)
end
local function ColorBlack()
SetC:FireServer("Black")
RedButton.Choose.Visible = false
OrangeButton.Choose.Visible = false
YellowButton.Choose.Visible = false
GreenButton.Choose.Visible = false
LBlueButton.Choose.Visible = false
DBlueButton.Choose.Visible = false
PurpleButton.Choose.Visible = false
PinkButton.Choose.Visible = false
WhiteButton.Choose.Visible = false
BlackButton.Choose.Visible = true
ColorUI(0, 0, 0)
end
RedButton.MouseButton1Down:Connect(function()
ColorRed()
end)
YellowButton.MouseButton1Down:Connect(function()
ColorYellow()
end)
OrangeButton.MouseButton1Down:Connect(function()
ColorOrange()
end)
GreenButton.MouseButton1Down:Connect(function()
ColorGreen()
end)
LBlueButton.MouseButton1Down:Connect(function()
ColorLBlue()
end)
DBlueButton.MouseButton1Down:Connect(function()
ColorDBlue()
end)
PurpleButton.MouseButton1Down:Connect(function()
ColorPurple()
end)
PinkButton.MouseButton1Down:Connect(function()
ColorPink()
end)
WhiteButton.MouseButton1Down:Connect(function()
ColorWhite()
end)
BlackButton.MouseButton1Down:Connect(function()
ColorBlack()
end)
Script B
local RS = game:GetService("ReplicatedStorage")
local Folder = RS:WaitForChild("Misc")
local SetC = Folder:WaitForChild("SetColor")
local GrabC = Folder:WaitForChild("GrabColor")
local RedButton = script.Parent:WaitForChild("1Red")
local OrangeButton = script.Parent:WaitForChild("2Orange")
local YellowButton = script.Parent:WaitForChild("3Yellow")
local GreenButton = script.Parent:WaitForChild("4Green")
local LBlueButton = script.Parent:WaitForChild("5LightBlue")
local DBlueButton = script.Parent:WaitForChild("6DarkBlue")
local PurpleButton = script.Parent:WaitForChild("7Purple")
local PinkButton = script.Parent:WaitForChild("8Pink")
local WhiteButton = script.Parent:WaitForChild("9White")
local BlackButton = script.Parent:WaitForChild("99Black")
local MainUI = script.Parent.Parent.Parent.Parent
local Announcements = MainUI:WaitForChild("Announcements")
local CommandList = MainUI:WaitForChild("CommandList")
local Criminal = MainUI:WaitForChild("Criminal")
local MainOpen = MainUI:WaitForChild("MainOpen")
local Message = MainUI:WaitForChild("Message")
local ModMessage = MainUI:WaitForChild("ModMessage")
local SRT = MainUI:WaitForChild("SRT")
local TacticalArmor = MainUI:WaitForChild("TacticalArmor")
local UserLevel = MainUI:WaitForChild("UserLevel")
local UserS = MainUI:WaitForChild("UserSettings")
local function ColorUI(R, G, B)
Announcements.Title.BackgroundColor3 = Color3.fromRGB(R, G, B)
CommandList.TextLabel.BackgroundColor3 = Color3.fromRGB(R, G, B)
CommandList.Color.BackgroundColor3 = Color3.fromRGB(R, G, B)
Criminal.Title.BackgroundColor3 = Color3.fromRGB(R, G, B)
MainOpen.Menu.BackgroundColor3 = Color3.fromRGB(R, G, B)
MainOpen.Color.BackgroundColor3 = Color3.fromRGB(R, G, B)
MainOpen.RRT.Color.BackgroundColor3 = Color3.fromRGB(R, G, B)
ModMessage.TextLabel.BackgroundColor3 = Color3.fromRGB(R, G, B)
ModMessage.Color.BackgroundColor3 = Color3.fromRGB(R, G, B)
SRT.Title.BackgroundColor3 = Color3.fromRGB(R, G, B)
TacticalArmor.TextLabel.BackgroundColor3 = Color3.fromRGB(R, G, B)
UserLevel.TextLabel.BackgroundColor3 = Color3.fromRGB(R, G, B)
UserS.TextLabel.BackgroundColor3 = Color3.fromRGB(R, G, B)
UserS.Return.BackgroundColor3 = Color3.fromRGB(R, G, B)
print (R, G, B) ----- THIS SUCCESSFULLY PRINTS WITH THE CORRECT RGB COLOR. But the lines above did not work and there is no error.
end
local function ColorRed()
SetC:FireServer("Red")
RedButton.Choose.Visible = true
OrangeButton.Choose.Visible = false
YellowButton.Choose.Visible = false
GreenButton.Choose.Visible = false
LBlueButton.Choose.Visible = false
DBlueButton.Choose.Visible = false
PurpleButton.Choose.Visible = false
PinkButton.Choose.Visible = false
WhiteButton.Choose.Visible = false
BlackButton.Choose.Visible = false
ColorUI(255, 105, 84)
end
local function ColorOrange()
SetC:FireServer("Orange")
RedButton.Choose.Visible = false
OrangeButton.Choose.Visible = true
YellowButton.Choose.Visible = false
GreenButton.Choose.Visible = false
LBlueButton.Choose.Visible = false
DBlueButton.Choose.Visible = false
PurpleButton.Choose.Visible = false
PinkButton.Choose.Visible = false
WhiteButton.Choose.Visible = false
BlackButton.Choose.Visible = false
ColorUI(255, 170, 0)
end
local function ColorYellow()
SetC:FireServer("Yellow")
RedButton.Choose.Visible = false
OrangeButton.Choose.Visible = false
YellowButton.Choose.Visible = true
GreenButton.Choose.Visible = false
LBlueButton.Choose.Visible = false
DBlueButton.Choose.Visible = false
PurpleButton.Choose.Visible = false
PinkButton.Choose.Visible = false
WhiteButton.Choose.Visible = false
BlackButton.Choose.Visible = false
ColorUI(220, 222, 72)
end
local function ColorGreen()
SetC:FireServer("Green")
RedButton.Choose.Visible = false
OrangeButton.Choose.Visible = false
YellowButton.Choose.Visible = false
GreenButton.Choose.Visible = true
LBlueButton.Choose.Visible = false
DBlueButton.Choose.Visible = false
PurpleButton.Choose.Visible = false
PinkButton.Choose.Visible = false
WhiteButton.Choose.Visible = false
BlackButton.Choose.Visible = false
ColorUI(67, 153, 47)
end
local function ColorLBlue()
SetC:FireServer("LBlue")
RedButton.Choose.Visible = false
OrangeButton.Choose.Visible = false
YellowButton.Choose.Visible = false
GreenButton.Choose.Visible = false
LBlueButton.Choose.Visible = true
DBlueButton.Choose.Visible = false
PurpleButton.Choose.Visible = false
PinkButton.Choose.Visible = false
WhiteButton.Choose.Visible = false
BlackButton.Choose.Visible = false
ColorUI(71, 169, 234)
end
local function ColorDBlue()
SetC:FireServer("DBlue")
RedButton.Choose.Visible = false
OrangeButton.Choose.Visible = false
YellowButton.Choose.Visible = false
GreenButton.Choose.Visible = false
LBlueButton.Choose.Visible = false
DBlueButton.Choose.Visible = true
PurpleButton.Choose.Visible = false
PinkButton.Choose.Visible = false
WhiteButton.Choose.Visible = false
BlackButton.Choose.Visible = false
ColorUI(60, 77, 164)
end
local function ColorPurple()
SetC:FireServer("Purple")
RedButton.Choose.Visible = false
OrangeButton.Choose.Visible = false
YellowButton.Choose.Visible = false
GreenButton.Choose.Visible = false
LBlueButton.Choose.Visible = false
DBlueButton.Choose.Visible = false
PurpleButton.Choose.Visible = true
PinkButton.Choose.Visible = false
WhiteButton.Choose.Visible = false
BlackButton.Choose.Visible = false
ColorUI(144, 91, 178)
end
local function ColorPink()
SetC:FireServer("Pink")
RedButton.Choose.Visible = false
OrangeButton.Choose.Visible = false
YellowButton.Choose.Visible = false
GreenButton.Choose.Visible = false
LBlueButton.Choose.Visible = false
DBlueButton.Choose.Visible = false
PurpleButton.Choose.Visible = false
PinkButton.Choose.Visible = true
WhiteButton.Choose.Visible = false
BlackButton.Choose.Visible = false
ColorUI(214, 122, 215)
end
local function ColorWhite()
SetC:FireServer("White")
RedButton.Choose.Visible = false
OrangeButton.Choose.Visible = false
YellowButton.Choose.Visible = false
GreenButton.Choose.Visible = false
LBlueButton.Choose.Visible = false
DBlueButton.Choose.Visible = false
PurpleButton.Choose.Visible = false
PinkButton.Choose.Visible = false
WhiteButton.Choose.Visible = true
BlackButton.Choose.Visible = false
ColorUI(205, 205, 205)
end
local function ColorBlack()
SetC:FireServer("Black")
RedButton.Choose.Visible = false
OrangeButton.Choose.Visible = false
YellowButton.Choose.Visible = false
GreenButton.Choose.Visible = false
LBlueButton.Choose.Visible = false
DBlueButton.Choose.Visible = false
PurpleButton.Choose.Visible = false
PinkButton.Choose.Visible = false
WhiteButton.Choose.Visible = false
BlackButton.Choose.Visible = true
ColorUI(0, 0, 0)
end
GrabC.OnClientEvent:Connect(function(SavedColor)
if SavedColor == "Red" then
ColorRed()
elseif SavedColor == "Orange" then
ColorOrange()
elseif SavedColor == "Yellow" then
ColorYellow()
elseif SavedColor == "Green" then
ColorGreen()
elseif SavedColor == "LBlue" then
ColorLBlue()
elseif SavedColor == "DBlue" then
ColorDBlue()
elseif SavedColor == "Purple" then
ColorPurple()
elseif SavedColor == "Pink" then
ColorPink()
elseif SavedColor == "White" then
ColorWhite()
elseif SavedColor == "Black" then
ColorBlack()
end
end)