I have a mouse click code that I am using to detect certain actions. It uses a debounce variable to avoid being activate multiple times while the code is still executing.
One of the action it triggers is a function that initiates a timer, the timer is just a while loop. The function is in a different script file.
I release the debounce before calling the timer function because if I don't the debounce will stay off until the player clicks on something else. Which means if they what to open a door (for example) after activating the timer they have to click it twice.
Although I have a work around, I was wondering why it wasn't triggering the debounce off.
Code:
Mouse.Button1Down:connect(function() --when mouse is click if debounce == true then --debouncer if Mouse.Target ~= nil then --if its not a nil value debounce = false --turn off clicks if Mouse.Target:FindFirstAncestor("frontdoor") then --front door was touched replicatedStorage.DoorState(Player, Mouse.Target) --change door to opposite state debounce = true --if not timer loop doesn't trigger debounce off print("debounce off") replicatedStorage.TimerControl(Player, true) --start timer elseif Mouse.Target:FindFirstAncestor("lockedDoor") then --locked door was touched replicatedStorage.LockedDoorState(Player, Mouse.Target) --change locked door state if player has key end end end debounce = true print("debounce off") end)`