BackgroundColor won't change

  1. What do you want to achieve?
    I want it so my crosshair goes gray when I start running.

  2. What is the issue?
    The prints for debugging ends up printing, but no color is changed. Other code changes the color but not this.

  3. What solutions have you tried so far?
    I’ve tried putting the piece of code in different parts of the script, but it didn’t work. I also tried changing from Color3.fromRGB to Color3.new and it didn’t work.
    There are no errors.

PlayerStuff.Values["Running"].Changed:Connect(function(Value)
		print('Value Changed')
		if PlayerStuff.Values["Running"].Value == true then 
			print('True')
			for _, CrossPart in pairs(CrossFrame:GetChildren()) do
				CrossPart.BackgroundColor3 = Color3.new(0.5, 0.5, 0.5) -- doesn't work
				print('DoubleTrue')
			end
		elseif PlayerStuff.Values["Running"].Value == false then
			print('False')
			for _, CrossPart in pairs(CrossFrame:GetChildren()) do
				CrossPart.BackgroundColor3 = Color3.new(1, 1, 1) -- doesn't work
				print('DoubleFalse') -- these end up printing anyway
			end
		end
	end)
2 Likes

Depends on from where u instance the ui. If it is from StarteGui then it wouldnt work, so try changing it to LocalPlayer:WaitForChild("PlayerGui") and instncing the ui from there.

Are they ImageLabels or frames? If not, are the frames dependent on BorderColor?

No, they are frames. Another piece of code checks if the Player is reloading, and makes the crosshair go grey, in which it works. I can change it to make it green, blue or whatever. However, when I apply this to check for when the player is running, the prints work but the color doesn’t change. Nothing in the rest of the code changes the color either.

It isn’t instancing from startergui.

Nevermind, the solution was that a piece of code rendered the crosshair which made it white, and I had to put a if statement under the rendercrosshair function to check if the player was running, and if so, it made it grey!