Hello, I'm trying to make a part change color when a different part is stepped on. Let's say, when "Part A" is being stepped on "Part B" will change it's color from Ghost grey to Bright yellow. But if you step off "Part A", "Part B" will change back to Ghost Grey. I'm pretty new to scripting, so this is probably very easy. I have no code for "Part A". Here is the code from "Part B".
```lua game.Workspace.Function.OnInvoke = function()
end
script.Parent.Touched:Connect(function()
script.Parent.BrickColor = BrickColor.new("Bright yellow")
end)
script.Parent.TouchEnded:Connect(function()
script.Parent.BrickColor = BrickColor.new("Ghost grey")
end) ```
```lua script.Parent.Touched:Connect(function()
script.Parent.Material = ("Neon")
end)
script.Parent.TouchEnded:Connect(function()
script.Parent.Material = ("SmoothPlastic")
end) ```
Could someone please help me?
I've created a little script that can help you in this case, Place it inside Part A:
script.Parent.touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then workspace.PartB.BrickColor = BrickColor.new("Bright yellow") end end) script.Parent.touchEnded:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then workspace.PartB.BrickColor = BrickColor.new("Ghost grey") end end)