so, i made a laser that detects things within a table and outputs a signal if there is, but if theres 2 parts in it at once and only one of them leaves it, the signal turns off which i dont want
local Laser = game.Workspace.DetectorModule.Laser
local SignalValue = game.Workspace.DetectorModule.Signal.Value
local ThingsInLaser = 0
local StuffToDetect = {
game.Workspace.Gem,
game.Workspace.Iron,
game.Workspace.RockChunk,
game.Workspace.Log.Bark,
game.Workspace.Log.Wood,
game.Workspace.Wood,
game.Workspace.FinishedWood.Wood
}
Laser.Touched:Connect(function(Hit)
if table.find(StuffToDetect, Hit) then
ThingsInLaser += 1
Laser.Parent.Signal.Value = true
else
SignalValue = SignalValue
end
end)
Laser.TouchEnded:Connect(function(HitEnd)
if table.find(StuffToDetect, HitEnd) then
ThingsInLaser -= 1
Laser.Parent.Signal.Value = false
else
SignalValue = SignalValue
end
end)
while wait() do
if ThingsInLaser >= 0 then
SignalValue = true
elseif ThingsInLaser <= 0 then
ThingsInLaser = 0
end
end