Hello! I’m not sure why, but the clickdetector function in my script’s loop runs as many times as the debounce within resets. This doesn’t happen to any other part of the loop besides this. I’ve provided the script and a picture example below.
while task.wait() do
print(rtc)
if rtc then
rtc = false
local direc = math.random(1,4)
print(direc)
local task = coroutine.create(cd)
local taskR = coroutine.resume(task)
for i,v in pairs(entire:GetChildren()) do
if v.ClassName == "Model" and v.Remain.Value == true then
local clicker = v:FindFirstChild(tostring(direc))
clicker.BrickColor = BrickColor.new("Lime green")
for i,part in pairs(v:GetChildren()) do
if part.ClassName == "Part" then
part.ClickDetector.MouseClick:Once(function()
print(part,clicker)
if tonumber(num) > 0 then
if part ~= clicker then
part.BrickColor = BrickColor.new("Really red")
v.Remain.Value = false
elseif part == clicker then
clicker.BrickColor = BrickColor.new("Institutional white")
v.Click.Value = true
end
elseif tonumber(num) == 0 then
for i,part in pairs(v:GetChildren()) do
if part.ClassName == "Part" then
part.BrickColor = BrickColor.new("Really red")
v.Remain.Value = false
end
end
end
end)
end
end
end
end
end
end