local function onRenderStep(deltaTime)--DeltaTime is the time (in seconds) that has elapsed since the previous frame
for _,v in pairs(doors:GetChildren())do
local sensor = v.Sensor
local distance = player:DistanceFromCharacter(sensor.Position)
local doorClosed = v.Closed
if distance < doorDetectionDistance and doorClosed.Value then--Opening door if in distance
doorClosed.Value = false
print("Opening door")
moveDoors(v,1)
elseif distance > doorDetectionDistance and doorClosed.Value == false then--closing door
moveDoors(v,-1)
doorClosed.Value = true
print("Door Closed")
end
end
end
RunService.RenderStepped:Connect(onRenderStep)
"Opening door" prints once, but when I walk away "Door Closed" prints multiple times. Usually 37times

1 comment
please mark my answer as the correct answer, thanks!