So basically I have been looking around trying to make a door that will open and close with an animation, like the ones in Jailbreak and I can't find out how to do so. I would greatly appreciate it if someone could help me.
✓ ANSWER ACCEPTED
I can't figure out how to make a door open and close with an animation.Can someone help me?
1 answer
✓ Accepted answer
Alright so I'll cover each form of movement that can be performed.
- Tween This can be used only on Parts within the Workspace (or Guis, but that doesn't pertain to this) Tweens will move an object in a way that will make it reach its destination smoothly
The following is an example script
local TweenService = game:GetService("TweenService")
local timer = 5
local tweenInfo = TweenInfo.new(timer)
function MoveIt()
local goal = {}
goal.CFrame = CFrame.new(100, 2.5, 100) -- Target Position
local part = workspace.TweenMod.Part
local tween = TweenService:Create(part, tweenInfo, goal)
tween:Play()
wait(timer)
end
script.Parent.TextButton.Activated:Connect(MoveIt)
The CFrame may also be replaced with Position if you don't need rotation to occur. Although tedious, you could also have each part in a model play a tween at the same time, as long as they are pre-defined.
tween1:Play()
tween2:Play()
wait(timer)
- SetPrimaryPartCFrame This can be used only on Models within the Workspace This type of movement may be appear choppy depending on the size of the model and the time it takes to get to a certain point. It also requires that the primarypart is set to one of the model's children
The following is an example script
repeat
script.Parent:SetPrimaryPartCFrame(script.Parent.Part.CFrame + Vector3.new(0, 0, 0.1)) -- increment to move
wait()
until script.Parent.Part.CFrame == CFrame.new(0, 0, 0) -- When to end the movement
- Animations This can be used on a Model if it contains an animation controller or a humanoid w/ an animator These can be used for more complex movements, but must be custom made using the animation editor in Studio
The following is an example script for playing the animation
local animation = script.Parent
local animPlayer = workspace.Model.Humanoid:LoadAnimation(animation)
repeat
animPlayer:Play()
wait(2) -- or however long the animation is set to last for
until script.Parent.TurnOff.Value == false
This discussion is preserved as it was. New answers, comments, and votes are closed.

4 comments
Have you tried any amount of scripting to do so, or are you completely lost? You can make the door move in one of two ways: Using Tweens, or using an Animation, Tweens are better for geometic movement, Animation means you could break the whole door apart and reassemble it. Choose your preference.
I know how to script I'm just not sure of how to use Tweens to move the door how I want it to move.
alright, well if you want to do tweens i can give an example in the answers section? of course i'd need to know if the door is a model or a singular part
I would like to assume it is a model because it will have a door handle.