Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Animator = {}
- local ResumeSpeed = 0
- function GetOrSetAnimationFolder()
- local folder = game.Workspace:FindFirstChild("AsamiAnimatorFolder")
- if folder then
- return folder
- else
- local newFolder = Instance.new("Folder")
- newFolder.Name = "AsamiAnimatorFolder"
- newFolder.Parent = workspace
- return newFolder
- end
- end
- function Animator.PlayAnimation(KeyframeSequence, character)
- if not KeyframeSequence:IsA("KeyframeSequence") then
- print("Aborting animation, please insert a KeyFrameSequence")
- return
- end
- if character.Humanoid:FindFirstChild("CurrentAnimation") then
- Animator.StopAnimation(character.Humanoid.CurrentAnimation.Value)
- end
- local newAnimation = script.PlayingAnimation:Clone()
- newAnimation:WaitForChild("Speed").Value = 1
- newAnimation:WaitForChild("Target").Value = character
- newAnimation:WaitForChild("AnimationPlayer"):WaitForChild("Origin").Value = newAnimation
- local newKFS = KeyframeSequence:Clone()
- newKFS.Parent = newAnimation
- newAnimation.AnimationPlayer:WaitForChild("Animation").Value = newKFS
- newAnimation.AnimationPlayer:WaitForChild("Rig").Value = character
- newAnimation.Parent = GetOrSetAnimationFolder()
- newAnimation.Disabled = false
- return newAnimation
- end
- function Animator.StopAnimation(AsamiAnimation)
- if AsamiAnimation:IsA("Script") and AsamiAnimation:FindFirstChild("StopAnimationControl") then
- AsamiAnimation.StopAnimationControl.OnStopCall:Invoke()
- else
- print("You tried to stop a value that is not an animation. Please insert the value returned by 'PlayAnimation'")
- end
- end
- function Animator.ChangeAnimationSpeed(AsamiAnimation, speed)
- if AsamiAnimation:IsA("Script") and AsamiAnimation:FindFirstChild("StopAnimationControl") then
- AsamiAnimation.Speed.Value = speed
- else
- print("You tried to change the speed of a value that is not an animation. Please insert the value returned by 'PlayAnimation'")
- end
- end
- function Animator.PauseAnimation(AsamiAnimation)
- if AsamiAnimation:IsA("Script") and AsamiAnimation:FindFirstChild("StopAnimationControl") then
- AsamiAnimation.ResumeSpeed.Value = AsamiAnimation.Speed.Value
- AsamiAnimation.Speed.Value = 0
- else
- print("You tried to pause a value that is not an animation. Please insert the value returned by 'PlayAnimation'")
- end
- end
- function Animator.ResumeAnimation(AsamiAnimation)
- if AsamiAnimation:IsA("Script") and AsamiAnimation:FindFirstChild("StopAnimationControl") then
- AsamiAnimation.ResumeSpeed.Value = AsamiAnimation.Speed.Value
- AsamiAnimation.Speed.Value = 0
- else
- print("You tried to resume a value that is not an animation. Please insert the value returned by 'PlayAnimation'")
- end
- end
- function Animator.StopAnimationOnHumanoid(humanoid)
- if humanoid:FindFirstChild("CurrentAnimation") then
- Animator.StopAnimation(humanoid.CurrentAnimation.Value)
- end
- end
- return Animator
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement