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)
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.
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)