Hello, I am trying to set running animation when they reach to speed 20. Is there a way to do that because It’s weird running and having the normal walk animation on. (R6 only)
First, find what the player’s running speed is. When the speed reaches 20, change the walking animation to running. If you have a running event, you can change the animation once the event fires.
You could try something like this:
local LP = game.Players.LocalPlayer
local LPC = LP.Character
LPC:WaitForChild("Humanoid").WalkSpeed.Changed:Connect(function()
if LPC.Humanoid.WalkSpeed == 20 then
local anim = --wherever your running animation is
if LPC.Humaoid.HumanoidStateType == Enum.HumanoidStateType.Running then
anim.Parent = LPC:FindFirstChild("HumanoidRootPart")
anim:Play()
end
end
end)
You can make a LocalScript
in StarterPlayer > StarterCharacterScripts
and copy this (Also sorry for the 3 edits, so many errors) code:
local Player = game.Players.LocalPlayer
local Character = Player.Character
local Humanoid = Character:WaitForChild("Humanoid")
RunningSpeed = 20
RunAnimationId = "rbxassetid://" .. "11262541237" -- Replace this string with your animation Id
local RunDefault
local WalkDefault
Humanoid.Running:Connect(function(Speed) -- Player's character is running
if Speed >= RunningSpeed then -- Speed is greater than or equal to the set running speed
RunDefault = Character.Animate.run.RunAnim.AnimationId
WalkDefault = Character.Animate.walk.WalkAnim.AnimationId
Character.Animate.run.RunAnim.AnimationId = RunAnimationId
Character.Animate.walk.WalkAnim.AnimationId = RunAnimationId
else -- Speed is lower than the set running speed (not greater than or equal to)
Character.Animate.run.RunAnim.AnimationId = RunDefault
Character.Animate.walk.WalkAnim.AnimationId = WalkDefault
end
end)
Hope this was useful.
It would actually probably be easier to fork the animation module roblox made and then add a case for when the player is at 20 speed.