Sensor not changing properties when part touches it

hi,
I’m trying to make a sensor that when a part touches it, it will change some properties of the surroundings like a signal change.
For some reason, the script doesn’t work at all.
((It is only supposed to work if a part called “Part” touches it.)
Thank you!
Horse
Script below.

script.Parent.Touched:connect(function(P)
    if P.Parent.Name == "Part" then
        script.Parent.Parent.Red.Material = "Neon"
        script.Parent.Parent.Red.Transparency = 0
        script.Parent.Parent.one.Material = "Plastic"
        script.Parent.Parent.one.Transparency = 0.95
        script.Parent.Parent.two.Material = "Plastic"
        script.Parent.Parent.two.Transparency = 0.95
        script.Parent.Parent.Green.Material = "Plastic"
        script.Parent.Parent.Green.Transparency = 0.95
        script.Parent.Material = "Neon"
        script.Parent.Parent.lime.Material = "Plastic"
        script.Parent.Parent.yellow.Material = "Plastic"
        script.Parent.Parent.double.Material = "Plastic"
        script.Parent.Parent.SPAD.a.CanCollide = true
        script.Parent.Parent.SPAD.b.CanCollide = true
        script.Parent.Parent.SPAD.c.CanCollide = true
        script.Parent.Parent.SPAD.d.CanCollide = true
    end
end)

If the idea is that the specific part that touched your sensor needs to be named Part then get rid of the Parent access from P. Your script is currently checking if the parent of the part that touched the sensor is named Part. It’s not that this code doesn’t work, it’s that your conditional is evaluating as false. It’s doing exactly what you’ve authored it to do; change properties if the hit part’s parent’s name is Part.

thank you, changing that asap!