If I click in the boundary, everything is fine. If I click outside the boundary it returns Out of bounds (x2), if I click outside again it returns Out of bounds (x8) and keeps increasing until it reaches something crazy like (x8432), when the game lags out and crashes.
function Place()
if Placing == true and Debounce == true then
Mouse.Button1Down:connect(function()
Debounce = false
if InBoundary == true and IsColliding == false and Placing == true then
-- irrelevant code
if Mouse.Target == nil then
return
end
if Placing == true then
Mouse.TargetFilter = nil
Placing = false
elseif not Placing then
return
end
Placing = false
elseif InBoundary == false then
print("Out of bounds.")
Blink()
Place()
elseif IsColliding == true then
print("Object already here.")
Blink()
Place()
end
Debounce = true
end)
end
end
How can I fix this? I tried adding a Debounce.

2 comments
Is this the whole script
you need to disconnect the function