Im currently trying to make an animation script that changes from walking to running anamations. I can’t get the animation to start up correctly.
local player = game.Players.LocalPlayer
local character = player.Character
repeat wait() until character
character.Humanoid:GetPropertyChangedSignal("WalkSpeed"):Connect(function(speed)
if speed ~= 16 then
character.Animate.walk.WalkAnim.AnimationId = "http://www.roblox.com/asset/?id=5941443471"
elseif speed == 16 then
character.Animate.walk.WalkAnim.AnimationId = "http://www.roblox.com/asset/?id=5941419010"
end
end)
Try adding an animation or two inside the script. Put the IDs in them and try this script
local player = game.Players.LocalPlayer
local character = player.Character
local humanoid = character:WaitForChild("Humanoid")
local animation = script.Parent.Animation
local secondAnimation = script.Parent.SecondAnimation
local doAnim = humanoid:LoadAnimation(animation)
local doSecondAnim = humanoid:LoadAnimation(secondAnimation)
repeat wait() until character
character.Humanoid:GetPropertyChangedSignal("WalkSpeed"):Connect(function(speed)
if speed ~= 16 then
doAnim:Play()
doSecondAnim:Stop()
elseif speed == 16 then
doAnim:Stop()
doSecondAnim:Play()
end
end)
Okay, so I got the animation to change when walking to running but it only changes when you either, stop, jump, or fall. But when I stop holding shift and I don’t stop walking the animation won’t change. This is the closest I have gotten. I tried the script you made in the video above and it doesn’t seem to swap smoothly or at all. Here is your script I edited:
local player = game.Players.LocalPlayer
local character = player.Character
local humanoid = character:WaitForChild("Humanoid")
local animation = script.Animation.AnimationId
local secondAnimation = script.SecondAnimation.AnimationId
repeat wait() until character
character.Humanoid:GetPropertyChangedSignal("WalkSpeed"):Connect(function()
if character.Humanoid.WalkSpeed == 24 then
character.Animate.walk.WalkAnim.AnimationId = animation
elseif character.Humanoid.WalkSpeed == 16 then
character.Animate.walk.WalkAnim.AnimationId = secondAnimation
end
end)