I want this script to run as long a player is touching it. Why doesn't it run at all?
repeat script.Parent.BrickColor = BrickColor.new("Institutional white") wait(1) script.Parent.BrickColor = BrickColor.new("Really black") wait(1) until script.Parent.TouchEnded
TouchEnded is an event, not a bool value. You can make it a bool value like this:
local partTouching = nil --The current part touching touch part. local touchPart = script.Parent --The brick to be used with this script. touchPart.Touched:connect(function(part) partTouching = part --Set the variable to the current touching part. repeat script.Parent.BrickColor = BrickColor.new("Institutional white") wait(1) script.Parent.BrickColor = BrickColor.new("Really black") wait(1) until not partTouching end) touchPart.TouchEnded:connect(function(part) --When the touch stops, this event is emitted. if part == partTouching then partTouching = nil --This part is no longer touching. end end)
If you have any questions or issues, feel free to comment below.