Door animation bug

i created simple door open/close script using animations, but they seem to be played twice, with the first half playing. I tried all animation priorities, all the same, only “HumanoidRootPart” is anchored. There is all model:


Here is script:

local Animations = game:GetService("ReplicatedStorage").Animations
local ClickDetector = script.Parent.Torso.ClickDetector
db = false

local Open = script.Parent.Humanoid.Animator:LoadAnimation(Animations.Open) -- Animation Priority = Enum.AnimationPriority.Action
local Close = script.Parent.Humanoid.Animator:LoadAnimation(Animations.Close) -- Animation Priority = Enum.AnimationPriority.Idle
local Holding = script.Parent.Humanoid.Animator:LoadAnimation(Animations.Holding) -- Animation Priority = Enum.AnimationPriority.Idle

ClickDetector.MouseClick:Connect(function()
  if db then
  Holding:Stop()
  Open:Stop(.3)
  Close:Play(.3)
  db = false
  else
    Close:Stop(.3)
  Open:Play()
  Holding:Play(.3)
  db = true
  end
  end)

And there is a bug:

1 Like

Why on earth are you using animations for this?

You can just tween the parts.

2 Likes

I need the door handle to twitch so that the door staggers after opening etc. Animation makes it easier to do

im sure you could use some easings like Back and Bounce to recreate the animation

i think he doesn’t want tweens because sometimes in larger games they can be REALLY laggy. Motors / Animations are probably way better in his case.

But yes I wonder the same, using humanoid animations and stuff for parts? That’s really weird. I would recommend just using Motor’s with welds to the door’s parts.

Can i create animation with a motor? Or does he helps with animating? I don’t know anything about the motor other than what offset cameras do with it :slight_smile:
If I use a motor, will it be possible to make an animation of twitching the handle? I need to somehow fix this

Like so it looks like you are opening the door by the handle going down in real life or?

No, just twitching the handle (even possible like in the video), it is possible without easings, I think it will still look good

You could tween the speed of the motors (not laggy) so that would probably be a great thing, you can also make it look like it’s a easing style you want by making it go (if you have the bouncy one) further than needed with a higher speed and then go back, it’s a little harder but would be efficient.

ok, I’ll take a closer look at the motors. Thanks a lot!

I think you should use tweening to open door its much better

I fixed this adding animation fade (Animation:Play(Fade))

local TweenService = game:GetService("TweenService")
local Animations = game:GetService("ReplicatedStorage").Animations
local Sounds = game:GetService("ReplicatedStorage").Sounds

local click = script.Parent.Torso.ClickDetector
local Open = script.Parent.Humanoid.Animator:LoadAnimation(Animations.Open)
local Close = script.Parent.Humanoid.Animator:LoadAnimation(Animations.Close)
local Holding = script.Parent.Humanoid.Animator:LoadAnimation(Animations.Holding)
Open.Priority = Enum.AnimationPriority.Idle
Close.Priority = Open.Priority
Holding.Priority = Enum.AnimationPriority.Movement

db = false 

click.MouseClick:Connect(function()
    if db then  
        click.MaxActivationDistance = 0
        if script.Parent.Torso:FindFirstChild("Open") then script.Parent.Torso.Open:Destroy() end
        wait(.2)
        Holding:Stop(.5)
        Open:Stop(.5)
        Close:Play(1.45)
        wait(.6)
        local s = Sounds.Close:Clone() s.Parent = script.Parent.Torso s:Play()
        click.MaxActivationDistance = 14
        db = false
    else     
        click.MaxActivationDistance = 0
        if script.Parent.Torso:FindFirstChild("Close") then script.Parent.Torso.Close:Destroy() end
        Holding:Stop(.5)
        Close:Stop(.5)
        Open:Play(1.2)
        local o = Sounds.Open:Clone() o.Parent = script.Parent.Torso o:Play()
        script.Parent.Torso.Open:Play()  
        wait(Open.Length)
        Holding:Play()
        click.MaxActivationDistance = 14
        db = true
    end
end)
1 Like