Hello! My first post here, I want to show y’all something that I think will be useful for a lot of people, I’ve had some problems with the default R6 Animate script so I made a new one way more simple,
less than 100 lines of code, very easy to read and to customize, the script nailed the base functionality of the default one, in-game they even look exactly the same!
If you want to know more I’ll leave a link here to the video I made where you will see this that I’ve just told you about and more: Roblox Studio BEGINNER Friendly R6 Animation Script Simple
It includes the animations I think are most important, but you can easily add more if needed. The code is short and easy to read, which makes editing simple.
Here is the code
local Character = script.Parent
local Humanoid = Character:WaitForChild("Humanoid")
local RootPart = Character:WaitForChild("HumanoidRootPart")
local Animator = Humanoid:WaitForChild("Animator")
local currentAnim = ""
local currentAnimTrack = nil
local animationTable = {}
-- Preload animations
local animations = {
-- here put your own anim iDs
idleAnimation = "http://www.roblox.com/asset/?id=180435571",
walkAnimation = "http://www.roblox.com/asset/?id=180426354",
jumpAnimation = "http://www.roblox.com/asset/?id=125750702",
fallAnimation = "http://www.roblox.com/asset/?id=180436148",
climbAnimation = "http://www.roblox.com/asset/?id=180436334",
sitAnimation = "http://www.roblox.com/asset/?id=178130996",
-- you can add your own animations, remember that they should play when humanoid enters a certain state or situation
}
for animName, animId in pairs(animations) do
local anim = Instance.new("Animation")
anim.AnimationId = animId
animationTable[animName] = anim
end
-- Stop all animations
local function StopAllAnimations()
if currentAnimTrack then
currentAnimTrack:Stop()
currentAnimTrack:Destroy()
currentAnimTrack = nil
end
end
-- Play animation by name
local function PlayAnimation(animName)
if animName == currentAnim then return end
StopAllAnimations()
currentAnim = animName
currentAnimTrack = Animator:LoadAnimation(animationTable[animName])
currentAnimTrack:Play()
end
local function onSeated()
PlayAnimation("sitAnimation")
end
-- Humanoid state change functions
local function onJumping()
PlayAnimation("jumpAnimation")
end
local function onClimbing(speed)
if math.abs(speed) > 0.2 then
if currentAnim ~= "climbAnimation" then
PlayAnimation("climbAnimation")
elseif currentAnimTrack then
currentAnimTrack:AdjustSpeed(1)
end
else
if currentAnimTrack then
currentAnimTrack:AdjustSpeed(0)
end
end
end
local function onFalling()
PlayAnimation("fallAnimation")
end
local function onRunning(speed)
if speed > 0.2 then
PlayAnimation("walkAnimation")
else
PlayAnimation("idleAnimation")
end
end
-- Connect humanoid state events
Humanoid.Seated:Connect(function()
StopAllAnimations()
PlayAnimation("sitAnimation")
end)
-- no swim anim, uses running animation instead
Humanoid.Swimming:Connect(onRunning)
Humanoid.Running:Connect(onRunning)
Humanoid.FreeFalling:Connect(onFalling)
Humanoid.Climbing:Connect(onClimbing)
Humanoid.Jumping:Connect(onJumping)
Humanoid.Died:Connect(function()
StopAllAnimations()
currentAnim = ""
end)
In Pastebin → -> → R6 Simplified Animate Script