Help with Error "Color is not a valid member of part"

  1. What do you want to achieve? Keep it simple and clear!
    I want all the parts inside the model of this tree to change colors when it reaches a certain threshold of health.

  2. What is the issue? Include screenshots / videos if possible!
    everything BUT the changing color part doesn’t work.


    This is the error in question (i really hope the embed works)

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    Tried skimming around the forums, but nothing really worked. Unless I did something incorrect, I’m really not sure. I’m fairly new to scripting and the sorts so any type of advice would be appreciated.

image
This is what the tree looks like

local tree = script.Parent
local treeHum = tree.Humanoid
local parts = {}


for i, part in pairs(tree:GetChildren()) do
	if part:isA("Part") then
		table.insert(parts, part)
	end
end

function healthChange()
	
	if tree:GetAttribute("health1") == false and treeHum.Health <= treeHum.MaxHealth * 3/4 then
		tree:SetAttribute("health1", true)
		for i, part in pairs(parts) do
			local r = part.color.R * 255
			local g = part.Color.G * 255
			local b = part.Color.B * 255
			
			part.color = Color3.fromRGB(r - 20, g - 20, b - 20)
			
		end
	end
end

treeHum:GetPropertyChangedSignal("Health"):Connect(healthChange)

The problem is that color needs to be capitalized here. Properties are case sensitive.

1 Like

I’m gonna start crying now from how simple this was

Thank you

1 Like

Don’t worry happens too the best of us. I recommend drying something called “rubber duck debugging” where you put something on a table and explain the problem and code too it and then usually it just clicks too you.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.