hey guys, so i have 2 animations. “raising hurley animation” and “aggressive run animation”. a hurley is a stick; something like a bat that is used in the Irish sport called hurling.
i’m trying to smoothly transition my raising hurley animation into the run animation. i have an NPC for this so when he gets close to me, he will raise the hurley, then he will have that run animation (which is looped) to be playing.
my problem is that after he raises the hurley, it just gets jittery or whatever and it is far from smooth. i appreciate any help ty!!
raising hurley animation:
aggressive run animation:
problem:
script:
local somedudethatfollowsu:Model = workspace.somedudethatfollowsu
local somedudethatfollowsuHumanoid:Humanoid = somedudethatfollowsu:WaitForChild("Humanoid")
local pfs = game:GetService("PathfindingService")
local RS = game:GetService("RunService")
local connection = nil
local canJumpDB = false
local Close = nil
local animFolder = somedudethatfollowsu:WaitForChild("Animations")
local animation:Animation = animFolder:FindFirstChild("animation")
local animTrack:AnimationTrack = nil
local animationIDTable = {
["BubblyRun"] = 1018548665,
["CartoonyRun"] = 837009922,
["KnightRun"] = 734325948,
["LevitationRun"] = 619543231,
["MageRun"] = 754635032,
["NinjaRun"] = 658830056,
["OldschoolRun"] = 5319900634,
["RobotRun"] = 619522386,
["RthroHeavyRun"] = 3236849826,
["RthroRun"] = 2510238627,
["StylishRun"] = 619512153,
["SuperheroRun"] = 619528716,
["ToyRun"] = 973766674,
["VampireRun"] = 1113740510,
["FriendlyRunAnim"] = 115085003035345,
["WerewolfRun"] = 1113750642,
["ZombieRun"] = 619536621,
RaiseHurleyAnim = 77303114281512,
LowerHurleyAnim = 138634039282164,
AggressiveRunAnim = 97199751061840
}
local function onHumanoidDied()
if connection then
connection:Disconnect()
end
end
game.Players.PlayerAdded:Connect(function(p)
p.CharacterAdded:Connect(function(c)
local Humanoid:Humanoid = c:WaitForChild("Humanoid")
local hurley:Tool = somedudethatfollowsu:FindFirstChild("hurley")
if hurley then
somedudethatfollowsuHumanoid:EquipTool(hurley)
end
Humanoid.Died:Connect(onHumanoidDied)
connection = RS.Heartbeat:Connect(function()
local mag = (somedudethatfollowsu.HumanoidRootPart.Position - c:WaitForChild("HumanoidRootPart").Position).Magnitude --c:WaitForChild("HumanoidRootPart").Position
somedudethatfollowsuHumanoid:MoveTo(c:WaitForChild("HumanoidRootPart").Position)
-- Check the distance
if mag <= 20 then
if animation then
if not animTrack or not animTrack.IsPlaying then
animation.AnimationId = "http://www.roblox.com/asset/?id="..animationIDTable["RaiseHurleyAnim"]
animTrack = somedudethatfollowsuHumanoid.Animator:LoadAnimation(animation)
animTrack:Play()
animTrack.Ended:Wait()
animation.AnimationId = "http://www.roblox.com/asset/?id="..animationIDTable["AggressiveRunAnim"] -- Replace with the appropriate animation ID
animTrack = somedudethatfollowsuHumanoid.Animator:LoadAnimation(animation)
animTrack:Play()
end
end
else
-- Stop the animation if the character is further than 10 units away
if animTrack and animTrack.IsPlaying then
animTrack:Stop()
end
end
end)
end)
end)
here is the solution for anyone who’s trying to do something like this.
for the animations:
i updated the animations.
raising hurley animation:
aggressive run animation:
i made a new animation event at the last keyframe of the first animation called “startNextAnimation”. this will start the next animation once it reaches the last keyframe of the first animation.
in order for an animation to run smoothly into another, i copied the last keyframes on my first animation and pasted those keyframes at the very start of my second animation.
local somedudethatfollowsu:Model = workspace:WaitForChild("somedudethatfollowsu")
local somedudethatfollowsuHumanoid:Humanoid = somedudethatfollowsu:WaitForChild("Humanoid")
local pfs = game:GetService("PathfindingService")
local RS = game:GetService("RunService")
local connection = nil
local canJumpDB = false
local animFolder = somedudethatfollowsu:WaitForChild("Animations")
local animation:Animation = animFolder:FindFirstChild("animation")
local animTrack:AnimationTrack = nil
local isAnimating = false
local isTransitioning = false
local animationIDTable = {
["BubblyRun"] = 1018548665,
["CartoonyRun"] = 837009922,
["KnightRun"] = 734325948,
["LevitationRun"] = 619543231,
["MageRun"] = 754635032,
["NinjaRun"] = 658830056,
["OldschoolRun"] = 5319900634,
["RobotRun"] = 619522386,
["RthroHeavyRun"] = 3236849826,
["RthroRun"] = 2510238627,
["StylishRun"] = 619512153,
["SuperheroRun"] = 619528716,
["ToyRun"] = 973766674,
["VampireRun"] = 1113740510,
["FriendlyRunAnim"] = 115085003035345,
["WerewolfRun"] = 1113750642,
["ZombieRun"] = 619536621,
RaiseHurleyAnim = 77303114281512,
LowerHurleyAnim = 138634039282164,
AggressiveRunAnim = 97199751061840
}
local function onHumanoidDied()
if connection then
connection:Disconnect()
end
end
game.Players.PlayerAdded:Connect(function(p)
p.CharacterAdded:Connect(function(c)
local playerHumanoid:Humanoid = c:WaitForChild("Humanoid")
local hurley:Tool = somedudethatfollowsu:FindFirstChild("hurley")
if hurley then
somedudethatfollowsuHumanoid:EquipTool(hurley)
end
playerHumanoid.Died:Connect(onHumanoidDied)
-- Disconnect any existing connection before creating a new one
if connection then
connection:Disconnect()
end
connection = RS.Heartbeat:Connect(function()
local mag = (somedudethatfollowsu:WaitForChild("HumanoidRootPart").Position - c:WaitForChild("HumanoidRootPart").Position).Magnitude
somedudethatfollowsuHumanoid:MoveTo(c:WaitForChild("HumanoidRootPart").Position)
if mag <= 20 then
if animation then
if not isAnimating then
isAnimating = true
-- Start RaiseHurleyAnim
if animTrack then
animTrack:Stop()
animTrack = nil
end
animation.AnimationId = "http://www.roblox.com/asset/?id="..animationIDTable["RaiseHurleyAnim"]
animTrack = somedudethatfollowsuHumanoid.Animator:LoadAnimation(animation)
animTrack:Play()
animTrack:GetMarkerReachedSignal("startNextAnimation"):Connect(function()
--Transition to AggressiveRunAnim
if not isTransitioning then
isTransitioning = true
animation.AnimationId = "http://www.roblox.com/asset/?id="..animationIDTable["AggressiveRunAnim"]
animTrack = somedudethatfollowsuHumanoid.Animator:LoadAnimation(animation)
animTrack:Play()
animTrack.Ended:Connect(function()
isAnimating = false
isTransitioning = false
end)
end
end)
end
end
else
-- Stop the animation if the character is further than 30 units away
if animTrack and animTrack.IsPlaying then
animTrack:Stop()
animTrack = nil
isAnimating = false
end
end
end) -- End of RS.Heartbeat:Connect
end) -- End of p.CharacterAdded:Connect
end) -- End of game.Players.PlayerAdded:Connect