Rod won't change color when I touch it with keycard

I am making a keycard detector, the rod won’t change color when I touch it.
Here is a picture of my creation(keycard) detector.

Here is where the script is.

Here is my script:

function onHit(hit)
	if hit.Parent.Name == "Card" then
		rod.Color = BrickColor.new("Bright green")
	else
		rod.Color = BrickColor.new("Bright red")
	end
end```

print the hit.Parent, as it is probably going to return the players character and not the card

Instead of referring to the part as rod, you should instead use script.Parent. You should also be changing the BrickColor property instead of Color. This should fix the issue:

script.Parent.Touched:Connect(function(hit)
    if hit.Parent.Name == "Card" then
         script.Parent.BrickColor = BrickColor.new("Bright green")
    else
         script.Parent.BrickColor = BrickColor.new("Bright red")
    end
end)

You could also add a cooldown and make the brick turn to its original color after a while.