The problem i have 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? Thank you Edit : I specify that I reduced the script to make it readable (otherwise there are 152 lines)
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
The problem is that there isn’t a debounce for the touching itself/the really red code. Since there is no debounce with it, the Lime green code will run every time the part is touched besides when it is running the debounce code. This means that every time the game registers a touch (which is quite a lot) on that part, it will turn lime green.
im pretty sure the problem is that they forgot to clear the table, so in my post i have added a clear for the table so that there are an infinite attempts
Unfortunately, this does not correct the problem. I can make the script work if I get the code right the first time but if I miss it then I can’t make the right code (I can still press the button but it will never work). But thanks a lot for ur help
remove that clear at the very end, im pretty sure it is executing whenever the part is touched and isnt inside of the statement that checks in the part touched has a humanoid