Advertisement
InTesting

Better Sit Animation

Jul 20th, 2021
1,666
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.59 KB | None | 0 0
  1. -- LuaU
  2. -- did this because the old script is pretty wack
  3. -- also idk about this its pretty untested
  4.  
  5. local SitAnimationObj = script.Parent.sitanim
  6.  
  7. local seat = script.Parent
  8. local anim
  9.  
  10. function Occupant_Changed(SitAnimationObj)
  11.     return function()
  12.         local Hum = seat.Occupant
  13.        
  14.         if Hum then
  15.             local animator = Hum:FindFirstChild'Animator'
  16.             anim = animator:LoadAnimation(SitAnimationObj) -- change if renamed
  17.             anim:Play()
  18.         elseif anim then
  19.             anim:Stop()
  20.             anim:Destroy()
  21.         end
  22.     end
  23. end
  24.  
  25. seat:GetPropertyChangedSignal('Occupant'):Connect(Occupant_Changed(Occupant_Changed))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement