Advertisement
HiddenKesh

HiddenDevs Animations Showcase

Sep 20th, 2024 (edited)
917
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.91 KB | Gaming | 0 0
  1. --!strict
  2. --[[
  3.  
  4. Please do not edit anything in this script!
  5.  
  6. A. Steps to setup this script:
  7.  
  8. 1. Create a LocalScript in StarterPlayer --> StarterPlayerScripts
  9. 2. Copy and paste this entire script in the LocalScript you created in Step A.1
  10.  
  11. B. Steps to setup animations:
  12.  
  13. 1. Create a Folder in Workspace
  14. 2. Name the folder as "Rigs"
  15. 3. Now create another folder (lets call it "RigFolder". The name doesn't matter) inside the folder you created in Step B.1 . This will the folder holding your Rig and Animation.
  16. 4. Add your Rig to RigFolder
  17. 5. Make an Animaion object inside RigFolder and set the AnimationId
  18. 6. Repeat Steps B.3 to B.5 for as many animations you want to submit.
  19.  
  20. Finally, Workspace should look something like this:
  21.  
  22. Workspace
  23.     Camera
  24.     Terrain
  25.     Rigs                        (Created in Step B.1)
  26.         Rig1                    (Name doesn't matter, Created in Step B.3)
  27.             Rig                 (Your rig, added in Step B.4)
  28.             Animation           (Created in Step B.5)
  29.         Rig2
  30.             Rig
  31.             Animation
  32.         Rig3
  33.             Rig
  34.             Animation
  35.            
  36. NOTE: Do not forget to add Humanoid or AnimationController instances to your rigs!
  37. Credits to: optimizedfunction        
  38. ]]
  39.  
  40.  
  41.  
  42.  
  43. local ContentProvider = game:GetService("ContentProvider")
  44. ContentProvider:PreloadAsync(workspace:GetDescendants())
  45.  
  46. local RigFolders: { Folder } = workspace:WaitForChild("Rigs"):GetChildren() :: { Folder }
  47.  
  48. for _, rigFolder in RigFolders do
  49.     local rig: Model? = rigFolder:FindFirstChildOfClass("Model")
  50.     if not rig then
  51.         warn("No Model instance (Rig) found in " .. rigFolder:GetFullName())
  52.         continue
  53.     end
  54.    
  55.     local animation: Animation? = rigFolder:FindFirstChildOfClass("Animation")
  56.     if not animation then
  57.         warn("No Animation instance found in " .. rigFolder:GetFullName())
  58.         continue
  59.     end
  60.    
  61.     -- checking for an Animator
  62.     local animator: Animator? = rig:FindFirstChildWhichIsA("Animator", true)
  63.     if not animator then
  64.        
  65.         local animController: AnimationController? | Humanoid? = rig:FindFirstChildWhichIsA("AnimationController", true) or rig:FindFirstChildWhichIsA("Humanoid", true)
  66.         if not animController then
  67.             warn("No Humanoid or AnimationController instance found in " .. rigFolder:GetFullName() .. "\nPlease manually add one in edit mode.")
  68.            
  69.             animController = Instance.new("AnimationController") :: AnimationController
  70.             animController.Parent = rig
  71.         end
  72.        
  73.         animator = Instance.new("Animator") :: Animator
  74.         animator.Parent = animController
  75.     end
  76.    
  77.     local animTrack: AnimationTrack = animator:LoadAnimation(animation)
  78.     animTrack:Play()
  79.     if not animTrack.Looped then
  80.         animTrack.Ended:Connect(function()
  81.             animTrack:Play()
  82.         end)
  83.     end
  84. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement