Hi, I'm making a door that when it's clicked it opens and when it's clicked again, it closes.
Yes, I know it's not the most ideal way to make a door script, but I already had it rigged up from making an animated film so I decided to just go with that.
I've made 4 animations:
~Idle Priority (looped = true)
• IdleOpen -- the default open position
• IdleClose -- the default closing position
~Action Priority (looped = false)
• Opening -- the animation that changes it from closed to open
• Closing -- the animation that changes it from open to closed
My issue is that the idle animation won't loop and the Action Priority Animations won't play a the same time
Here's the script:
local CD = script.Parent.ClickDetector
local Sound = script.Parent.PrimaryPart.Sound
local openAnimation = script:WaitForChild("Open")
local loadedOpenAnim
local idleopenAnimation = script:WaitForChild("IdleOpen")
local loadedidleOpenAnim
local closeAnimation = script:WaitForChild("Close")
local loadedCloseAnim
local idlecloseAnimation = script:WaitForChild("IdleClose")
local loadedidleCloseAnim
local isOpen = false
local humanoid = script.Parent:FindFirstChild("Humanoid")
CD.MouseClick:Connect(function()
if isOpen == true then
isOpen = false
if loadedidleOpenAnim then loadedidleOpenAnim:Stop() end
loadedidleCloseAnim = humanoid:LoadAnimation(closeAnimation)
loadedidleCloseAnim:Play()
loadedCloseAnim = humanoid:LoadAnimation(closeAnimation)
loadedCloseAnim:Play()
Sound:Play()
elseif isOpen == false then
isOpen = true
if loadedidleCloseAnim then loadedidleCloseAnim:Stop() end
loadedidleOpenAnim = humanoid:LoadAnimation(openAnimation)
loadedidleOpenAnim:Play()
loadedOpenAnim = humanoid:LoadAnimation(openAnimation)
loadedOpenAnim:Play()
Sound:Play()
end
end)
Any tips will be very much appreciated, Thanks
