Here's my script.
I tried using if Part:GetTouchingParts() ~= nil
but that didnt work to well as it wouldnt fire if there were no parts touching it to fire the event.
script.Parent.MeshPart1.Touched:Connect(function(Part) script.Parent.MeshPart1.BrickColor = BrickColor.new("Really red") script.Parent.MeshPart2.BrickColor = BrickColor.new("Really red") script.Parent.MeshPart3.BrickColor = BrickColor.new("Really red") end) script.Parent.MeshPart1.TouchEnded:Connect(function(Part) script.Parent.MeshPart1.BrickColor = BrickColor.new("Deep blue") script.Parent.MeshPart2.BrickColor = BrickColor.new("Deep blue") script.Parent.MeshPart3.BrickColor = BrickColor.new("Deep blue") end)
I couldn't really find any non laggy uncomplicated ways that dont involve things such as while true loops etc.
TouchEnded is only really useful for when a player walks through a large invisible part. I think if you made an invisible part the player had to walk through, and it was fairly thick, then you could set it up so while the player is inside that area touching it, the brick would stay that color, and when they stop touching or walk out of the area, the TouchEnded event would trigger. I personally hate using TouchEnded and it needs to be fixed in my opinion. Anyways, your script will work if you basically just make a thick hitbox the player walks through.
Here's an example of what I mean, just do yours with an invisible hitbox and instead of printing text, have it change the color, and your script is currently setup to pretty much do that. https://imgur.com/a/XQKfO
Try this with that method:
local touching = false script.Parent.MeshPart1.Touched:Connect(function(Part) if touching == false then script.Parent.MeshPart1.BrickColor = BrickColor.new("Really red") script.Parent.MeshPart2.BrickColor = BrickColor.new("Really red") script.Parent.MeshPart3.BrickColor = BrickColor.new("Really red") touching = true end end) script.Parent.MeshPart1.TouchEnded:Connect(function(Part) if touching == true then script.Parent.MeshPart1.BrickColor = BrickColor.new("Deep blue") script.Parent.MeshPart2.BrickColor = BrickColor.new("Deep blue") script.Parent.MeshPart3.BrickColor = BrickColor.new("Deep blue") touching = false end end)