Hello, I just wanted to know what this script does in a model I found, so I can try and make something simular on my own. If you could add a comment to each line it would be appreciated. Thanks, Jhunlzeus4.
function OpenDoors()
door.AccessGranted:play()
for i,v in pairs (DoorModel.Lights:GetChildren()) do
v.brickColor = BrickColor.new("Lime green")
end
door.DoorOpen:play()
for i=0,math.pi*2,math.pi/30 do
r.Stepped:wait()
door.CFrame=ret+Vector3.new(2.5,0,2.5)*look-math.cos(i)*2.5*look
door1.CFrame=ret1-Vector3.new(2.5,0,2.5)*look+math.cos(i)*2.5*look
if string.format("%3.2f",i)=="3.14" then
door.Transparency=1
door1.Transparency=1
wait(3)
door.Transparency=Original
door1.Transparency=Original1
door.DoorClose:play()
end
end
door1.CFrame = ret1
door.CFrame = ret
for i,v in pairs (DoorModel.Lights:GetChildren()) do
v.brickColor = BrickColor.new("Institutional white")
end
end

4 comments
It will open the door for you while animating it and will make lights on the door turn white... There you go, you have it all
Yes, but how does it make the door move? I want to understand how it works and how changing which argument would do what,
The door moves using CFrame - which is quite an advanced concept. I can barely understand this code properly myself. There are some resources on the wiki on how CFrame works. The CFrame gets changed every time it loops, which is shown by the for loop. We cannot teach you exactly how everything works - you'll need to read up on it and understand it all yourself.
it moves by using CFrame and Vector3.new and if it is a round door it will use pi because pi works for circles