Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

I can't figure out how to make a door open and close with an animation.Can someone help me? [closed]

Asked by 5 years ago

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.

0
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. SerpentineKing 3885 — 5y
0
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. Thunder878712817 -6 — 5y
0
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  SerpentineKing 3885 — 5y
0
I would like to assume it is a model because it will have a door handle. Thunder878712817 -6 — 5y

Closed as Not Constructive by LeadRDRK, zblox164, WideSteal321, starmaq, DinozCreates, SteamG00B, SerpentineKing, EpicMetatableMoment, and Azmidium

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

1 answer

Log in to vote
1
Answered by 5 years ago
Edited 5 years ago

Alright so I'll cover each form of movement that can be performed.

  1. 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)
  1. 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
  1. 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
Ad