Problem with Color Changing

So what I’m trying to do is The color of a Gui changes depending on the parts in the workspace

local function Change()
	local one = script.Parent.one
	local two = script.Parent.two
	local three = script.Parent.three
	local four = script.Parent.four
	local five = script.Parent.five
	local six = script.Parent.six
	one.BackgroundColor3 = workspace:FindFirstChild("One").walls.Part.Color
	two.BackgroundColor3 = workspace:FindFirstChild("Two").walls.Part.Color
	three.BackgroundColor3 = workspace:FindFirstChild("Three").walls.Part.Color
	four.BackgroundColor3 = workspace:FindFirstChild("Four").walls.Part.Color
	five.BackgroundColor3 = workspace:FindFirstChild("Five").walls.Part.Color
	six.BackgroundColor3 = workspace:FindFirstChild("Five").walls.Part.Color
end

while true do
	wait()
	Change()
end

But the Problem is it sets at the start of the game and when something changes it just stays the same, No errors. I dont know if anything is wrong with this.

try this

local one = script.Parent.one
local two = script.Parent.two
local three = script.Parent.three
local four = script.Parent.four
local five = script.Parent.five
local six = script.Parent.six

change = function()
	one.BackgroundColor3 = workspace:FindFirstChild("One").walls.Part.Color
	two.BackgroundColor3 = workspace:FindFirstChild("Two").walls.Part.Color
	three.BackgroundColor3 = workspace:FindFirstChild("Three").walls.Part.Color
	four.BackgroundColor3 = workspace:FindFirstChild("Four").walls.Part.Color
	five.BackgroundColor3 = workspace:FindFirstChild("Five").walls.Part.Color
	six.BackgroundColor3 = workspace:FindFirstChild("Five").walls.Part.Color
end

game:GetService("RunService").Heartbeat:Connect(function()
     change()
end)

thanks it worked :slight_smile:

1 Like