I'm making a script that uses a repeat until loop that initially triggers when its touched by a player.. The issue is, it always starts over every time the player moves around. Is there a way to make a script that runs as long as a player is touching a part?

Here is my attempt:

script.Parent.Touched:Connect(function(hit)
	repeat
		script.Parent.BrickColor = BrickColor.new("Institutional white")
		wait(1)
		script.Parent.BrickColor = BrickColor.new("Really black")
		wait(1)
	until script.Parent.TouchEnded
end)

5 comments

0

will you show your script, or not?

0

I don't have proper script yet. Right now I'm just making a part switch between black and white every second.

0

dont request on this site then

0

I want to know if there is a way to do it. I'll post a script then.

0

Happy?