Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --!strict
- --[[
- Please do not edit anything in this script!
- A. Steps to setup this script:
- 1. Create a LocalScript in StarterPlayer --> StarterPlayerScripts
- 2. Copy and paste this entire script in the LocalScript you created in Step A.1
- B. Steps to setup animations:
- 1. Create a Folder in Workspace
- 2. Name the folder as "Rigs"
- 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.
- 4. Add your Rig to RigFolder
- 5. Make an Animaion object inside RigFolder and set the AnimationId
- 6. Repeat Steps B.3 to B.5 for as many animations you want to submit.
- Finally, Workspace should look something like this:
- Workspace
- Camera
- Terrain
- Rigs (Created in Step B.1)
- Rig1 (Name doesn't matter, Created in Step B.3)
- Rig (Your rig, added in Step B.4)
- Animation (Created in Step B.5)
- Rig2
- Rig
- Animation
- Rig3
- Rig
- Animation
- NOTE: Do not forget to add Humanoid or AnimationController instances to your rigs!
- Credits to: optimizedfunction
- ]]
- local ContentProvider = game:GetService("ContentProvider")
- ContentProvider:PreloadAsync(workspace:GetDescendants())
- local RigFolders: { Folder } = workspace:WaitForChild("Rigs"):GetChildren() :: { Folder }
- for _, rigFolder in RigFolders do
- local rig: Model? = rigFolder:FindFirstChildOfClass("Model")
- if not rig then
- warn("No Model instance (Rig) found in " .. rigFolder:GetFullName())
- continue
- end
- local animation: Animation? = rigFolder:FindFirstChildOfClass("Animation")
- if not animation then
- warn("No Animation instance found in " .. rigFolder:GetFullName())
- continue
- end
- -- checking for an Animator
- local animator: Animator? = rig:FindFirstChildWhichIsA("Animator", true)
- if not animator then
- local animController: AnimationController? | Humanoid? = rig:FindFirstChildWhichIsA("AnimationController", true) or rig:FindFirstChildWhichIsA("Humanoid", true)
- if not animController then
- warn("No Humanoid or AnimationController instance found in " .. rigFolder:GetFullName() .. "\nPlease manually add one in edit mode.")
- animController = Instance.new("AnimationController") :: AnimationController
- animController.Parent = rig
- end
- animator = Instance.new("Animator") :: Animator
- animator.Parent = animController
- end
- local animTrack: AnimationTrack = animator:LoadAnimation(animation)
- animTrack:Play()
- if not animTrack.Looped then
- animTrack.Ended:Connect(function()
- animTrack:Play()
- end)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement