GUI won't show up when I touch a part more than once

You can write your topic however you want, but you need to answer these questions:
I’ve been trying to make a anti-wallclipping system where it would pop up a reminder every time you touch a window.

For some reason, when I touch the detection part the first time, it works fine. But after the first time I touch it, it doesn’t work. When I check the output, it doesn’t show any errors either.

I’ve tried to troubleshoot it sort of to print DETECTED every time it well, detects it. It prints it, the GUI just doesn’t show up. I’m not sure if this is a problem with the debounce I put or something.

local debounce = false
local ui = script.Parent.WCReminder.Frame
local detection = workspace.WallClippingDetection.DetectionPart
local cd = script.Parent.WCReminder.Frame.CD

detection.Touched:Connect(function()	
	if not debounce then
	debounce = true
	print("DETECTED")
	ui:TweenPosition(UDim2.new(0.298, 0,0.343, 0),"Out","Quint",1,false)	
	wait(5)
	cd.Text = "(This message will close in 10)"
	wait(1)	
	cd.Text = "(This message will close in 9)"
	wait(1)
	cd.Text = "(This message will close in 8)"
	wait(1)
	cd.Text = "(This message will close in 7)"
	wait(1)
	cd.Text = "(This message will close in 6)"
	wait(1)
	cd.Text = "(This message will close in 5)"
	wait(1)
	cd.Text = "(This message will close in 4)"
	wait(1)
	cd.Text = "(This message will close in 3)"
	wait(1)
	cd.Text = "(This message will close in 2)"
	wait(1)
	cd.Text = "(This message will close in 1)"
	wait(1)	
	ui:TweenPosition(UDim2.new(0.298, 0,-0.5, 0),"Out","Quint",1,false)	
	debounce = false
	end
	 
end)

I don’t know how to fix your problem but instead of making that long script to print that you can do this:

  for count = 10,1,-1 do
     print("This message will close in "..tostring(count))
     wait(1)
  end
1 Like

for a second i thought that fixed it because it worked 3 more times after i added that script, after the forth time, it stopped working : /

does the detectionpart have cancollide?

actually for some reason it works at random intervals, if I wait like 10 seconds or so after the gui closes, it works again.

yea can collide is enabled im not so sure how to reply a yes without it blocking the message but

is it because of the debounce? there is a 10 second wait in the function…

i don’t think so, the debounce resets at the end, but let me try removing the count down

nope, I replaced the count down with a 1 second wait and it still doesnt reappear the second time i touch it. I tried fidgeting with the positions see if that was the problem without any luck either.

Can you take a video showing the problem?

so it turns out that the ui works, its just that you have to wait a couple seconds before you can touch it again, which might be a problem if someone keeps trying to glitch in continuously.

The issue is at the end when you are changing the debounce value to false. The tween that makes it leave the screen overrides the tween that make it go into the screen. Meaning there is a tween conflict happening. You can fix that by adding a wait(1) which is the same length as the end tween so it helps avoid tween conflict.

Video:

Fixed code:

local debounce = false
local ui = script.Parent.WCReminder.Frame
local detection = workspace.WallClippingDetection.DetectionPart
local cd = script.Parent.WCReminder.Frame.CD

local time = 3

detection.Touched:Connect(function()	
	if not debounce then
		debounce = true
		print("DETECTED")
		ui:TweenPosition(UDim2.new(0.298, 0,0.343, 0),"Out","Quint",1,false)	
		for count = time,1,-1 do
			print("This message will close in "..tostring(count))
			cd.Text = "This message will close in " .. count
			wait(1)
		end
		ui:TweenPosition(UDim2.new(0.298, 0,-0.5, 0),"Out","Quint",1,false)	
		wait(1)
		debounce = false
	end

end)

you legend thank you so much, it was such a small fix but it works now thanks!

1 Like

I knew it was something to do with the end, I just didn’t know what to do to fix it.

1 Like