GUI doesn't stay open with a touched function on part

Hi there, I have this part that toggles a GUI when you walk on it. The issue is, is that while walking on the part, it constantly toggles the gui instead of staying open. What I’m trying to achieve is so that if you walk on this part, the GUI toggles and stays like that and when you walk off, the gui untoggles.

shop.Touched:Connect(function()
	if gui.Position == UDim2.new(0.5,0,1.302,0) then
		gui:TweenPosition(
			UDim2.new(0.5,0,0.5,0),

			"Out",
			"Sine",
			.5,
			false
		)	
	else
		gui:TweenPosition(
			UDim2.new(0.5,0,1.302,0),

			"Out",
			"Sine",
			.5,
			false
		)	
	end	

end)

Since you move your character’s feet when walking, they lift off the part, so they fire a new touched event. You could try lifting the part to a higher position, so that the players body touches the part constantly.

1 Like

Ohh, I’ll try that. This would also have to mean I’d turn collisions off for that part.

try using debounce atleast 1 second ?

1 Like

You should also add a debounce of 0.5 seconds to prevent multiple tweens from attempting to play over one another.

1 Like