Hello, as you can see on the video, the debounce I added on the action makes the action definitively interrupted. I’m looking for a way to put a timing to make the action possible after a few seconds. Does anyone know how I could do this? I have tried several scripts without success. The part of the script I put is cut from the real script (which is too long). Thanks
else
if debounce == 1 then
debounce = 2
print("hiiiiiiiiiiii")
bon1.BrickColor = BrickColor.new("Really red")
bon2.BrickColor = BrickColor.new("Really red")
wait(1)
bon1.BrickColor = BrickColor.new("Gold")
bon2.BrickColor = BrickColor.new("Gold")
end
end
indeed it works thanks, but I don’t understand because when I do that, my script doesn’t work anymore, as if it deactivates the functions I put. It would do the same to me if I set
“”"".CanTouch = false
wait(5)
“”"".CanTouch = true
I don’t know how to make my script still active ? if you have an idea ? I’ll wait a few minutes so that you can see it and then I’ll put the solution (because after all you have correctly done what the title asked).
Thanks a lot
edit : tell me if my explanations are not understandable
Roblox signals are like coroutines, they can be ran multiple times at once which means that temporarily disabling the .touched functionality in a .touched function won’t affect the signal function that is currently being executed
in fact the problem is that if I execute directly the good code then the result will be good, on the other hand if I execute the bad code and then I carry out the good code then it will not work and will put that I carried out the bad code, that cancels the good action. Without the debounce it doesn’t do that (but then there is the bouncing which is not good for the server). Is there any way to counter this? I can send the whole script but it is quite long. thank you
local plr = game.Players.LocalPlayer
local hitOrder = {}
local bon1 = workspace.bon1
local bon2 = workspace.bon2
local ouverture2 = workspace.ouverture2
local recompense = game.Workspace.recompense
local debounce = 1
bon1.Touched:Connect(function(hit)
if hit.Parent:FindFirstChildOfClass("Humanoid") then
bon1.BrickColor = BrickColor.new("Daisy orange")
if not table.find(hitOrder, bon1) then
table.insert(hitOrder, bon1)
end
end
end)
bon2.Touched:Connect(function(hit)
if hit.Parent:FindFirstChildOfClass("Humanoid") then
bon2.BrickColor = BrickColor.new("Daisy orange")
if not table.find(hitOrder, bon2) then
table.insert(hitOrder, bon2)
end
end
end)
ouverture2.Touched:Connect(function(hit)
if hit.Parent:FindFirstChildOfClass("Humanoid") then
if hitOrder[1] == bon1 and hitOrder[2] == bon2 then
bon1.BrickColor = BrickColor.new("Lime green")
bon2.BrickColor = BrickColor.new("Lime green")
recompense.Transparency = 1
ouverture2.CanTouch = false
else
if debounce == 1 then
debounce = 2
print("hiiiiiiiiiiii")
bon1.BrickColor = BrickColor.new("Really red")
bon2.BrickColor = BrickColor.new("Really red")
wait(1)
bon1.BrickColor = BrickColor.new("Gold")
bon2.BrickColor = BrickColor.new("Gold")
wait(5)
debounce = 1
end
this is the script, I deleted a lot of “unnecessary” lines to make it shorter