local door = script.Parent
local distance = 5
local function isClose()
for _, player in pairs(game.Players:GetPlayers()) do
if player.Character ~= nil and player:DistanceFromCharacter(door.Position) <= distance then
return true
end
end
return false
end
local function Open()
for i = 1, 70 do
door.CFrame = door.CFrame*CFrame.new(0, 0.5, 0)
wait()
end
end
local function Close()
for i = 70, 1 do
door.CFrame = door.CFrame*CFrame.new(0, 0.5, 0)
wait()
end
end
while true do
wait()
if isClose() then
Open()
else
Close()
end
wait()
end
The purpose is for the door to open/close based on how far away the player is from the door's position.
The door opens, however it does not close, unfortunately.
Help would be > greatly < appreciated.

2 comments
Change the second if to elseif, and take off one end
Use the :DistanceFromCharacter() of the player object.