Hello, I made a script where when you walk on a part it does something and when you go walk on another part it does the opposite of the other part's actions.
When you walk over the main part:
local Touched = false
script.Parent.Touched:Connect(function(hit)
if not Touched then
Touched = true
print("It made it inside an if statement")
-- Code that I would do here
wait(5)
print(Touched)
Touched = false
end
end)
Here is when you go walk over the other part:
local DoneTouching = false
script.Parent.Touched:Connect(function(hit)
if not DoneTouching then
DoneTouching = true
if hit.Parent:FindFirstChild("Something", true) then
-- Code in here
end
wait(3)
DoneTouching = false
end
end)
By the way I tested it without debounces and it worked perfectly fine but I need debounces for optimization. Thank you for reading and I hope that you can help, as it would be amazing!

2 comments
See what happens without the wait just for testing
Yeah I tried it with no waits and it doesn't work still... It will work the first or second time but then it will just stop working.