My number value doesn't change whenever the script runs through it. The change is at line 38.
local UserInputService = game:GetService("UserInputService")
local doors = game.Workspace.Doors:GetChildren()
local player = game.Players.LocalPlayer
local slow = 0
local function onInputBegan(InputObject, gameProcessedEvent)
for i , v in pairs(doors) do
local open = v.open.Value
if math.ceil((v.Part.Position - player.Character.Head.Position).Magnitude) <= 10 then
if InputObject.KeyCode == Enum.KeyCode.E and open == 0 then
local doormodel = v
v = doormodel
local door = doormodel.Part
local X = door.Position.X
local endX = X - 2.9
local Y = door.Position.Y
local Z = door.Position.Z
local Z2 = Z
local endZ = Z + 2.6
local rotate = door.Orientation.Y
local angle = math.rad(rotate)
local angle2 = math.rad(rotate)
local angleend = angle + math.rad(90)
if slow == 0 then
if math.ceil((door.Position - player.Character.Head.Position).Magnitude) <= 10 then
if rotate == 0 then -- 0 degrees
while true do
if angle < angleend and endZ > Z then
door.CanCollide = false
door.CFrame = CFrame.new(X + 0.13,Y,Z + 0.155) * CFrame.Angles(0,angle + math.rad(4.5),0)
angle = angle + math.rad(4.5)
X = X + 0.13
Z = Z + 0.155
wait(0.005)
slow = 1
else
door.CanCollide = true
open = open + 1
slow = 0
wait(0.05)
break
end
end
elseif rotate == -90 then -- -90 degrees
while true do
if angle < angleend and endZ > Z then
door.CanCollide = false
door.CFrame = CFrame.new(X - 0.145,Y,Z + 0.13) * CFrame.Angles(0,angle + math.rad(4.5),0)
angle = angle + math.rad(4.5)
X = X - 0.145
Z = Z + 0.13
wait(0.005)
slow = 1
else
door.CanCollide = true
open = open + 1
slow = 0
wait(0.05)
break
end
end
end
end
end
elseif InputObject.KeyCode == Enum.KeyCode.E and open == 1 then
local doormodel = v
v = doormodel
local door = doormodel.Part
local X = door.Position.X
local endX = X - 2.9
local Y = door.Position.Y
local Z = door.Position.Z
local Z2 = Z
local endZ = Z + 2.6
local rotate = door.Orientation.Y
local angle = math.rad(rotate)
local angle2 = math.rad(rotate)
local angleend = angle + math.rad(90)
if math.ceil((door.Position - player.Character.Head.Position).Magnitude) <= 10 then
if rotate == 90 then -- 0 degrees
while true do
if angle > angle2 and Z2 < Z then
door.CanCollide = true
door.CFrame = CFrame.new(X - 0.13,Y,Z - 0.155) * CFrame.Angles(0,angle - math.rad(4.5),0)
angle = angle - math.rad(4.5)
X = X - 0.13
Z = Z - 0.155
slow = 1
wait(0.005)
else
open = open -1
slow = 0
wait(0.05)
break
end
end
elseif rotate == 0 then -- -90 degress
while true do
if angle > angle2 and Z2 < Z then
door.CanCollide = true
door.CFrame = CFrame.new(X + 0.145,Y,Z - 0.13) * CFrame.Angles(0,angle - math.rad(4.5),0)
angle = angle - math.rad(4.5)
X = X + 0.145
Z = Z - 0.13
wait(0.005)
slow = 1
else
open = open - 1
slow = 0
wait(0.05)
break
end
end
end
end
end
end
end
end
UserInputService.InputBegan:Connect(onInputBegan)

5 comments
is it a local script?
yes
Does it return any errors?
no
We both answered. I hope you can get it work!