I’ve found this really good script on some other devforum post, so thanks to whoever put the time making this! But, theres a problem, for some reason the animations do not play. I’ve done some tweaking and testing to see if the script is functional, and all seems well, but the animations just don’t play.
Basically, the script detects whenever the player walks in a certain direction. For example, I move my character forward, the script detects this change and so changes the main walking animation (run anim in animate script) to the forward walking animation id. I can prove this works by printing which direction the character walks to and the change in animation ID
default run animation id is 11413856593
Ex 1)
This script is open source and can be found here
local Character = script.Parent.Parent
local Humanoid = Character:WaitForChild("Humanoid")
local HumanoidRoot = Character:WaitForChild("HumanoidRootPart")
-----AnimationHandler
local Animate = script.Parent
local RelativeWalk = script.RelativeWalk
---Animations' Names
local WalkF = RelativeWalk.WalkAnimFront
local WalkB = RelativeWalk.WalkAnimBack
local WalkR = RelativeWalk.WalkAnimRight
local WalkL = RelativeWalk.WalkAnimLeft
----MainWalk^^^
local MainWalk = script.Parent.run.RunAnim
-----Varibles
local RunSer = game:GetService("RunService")
--(*)
local CurrentAnim = nil
-----Functions^^}
function ToWalkRelativeToHRP(Humanoid, Direction, RootCompare)
-----Check if player is moving
if Direction ~= nil then
----X-x-x Continue
local RootFacing = RootCompare.CFrame.LookVector
local RootRight = RootCompare.CFrame.RightVector
local DirectionRelativeToRootFront = RootFacing:Dot(Direction, RootFacing)
local DirectionRelativeToRootSides = RootRight:Dot(Direction, RootRight)
----
local Output = nil
if DirectionRelativeToRootFront <= 1 and DirectionRelativeToRootFront >= 0.75 then
Output = "Forwards"
MainWalk.AnimationId = WalkF.AnimationId
elseif DirectionRelativeToRootFront >= -1 and DirectionRelativeToRootFront <= -0.75 then
Output = "Backwards"
MainWalk.AnimationId = WalkB.AnimationId
elseif DirectionRelativeToRootSides <= 1 and DirectionRelativeToRootSides >= 0.75 then
Output = "Right"
MainWalk.AnimationId = WalkR.AnimationId
elseif DirectionRelativeToRootSides >= -1 and DirectionRelativeToRootSides <= -0.75 then
Output = "Left"
MainWalk.AnimationId = WalkL.AnimationId
end
return Output
end
end
RunSer.RenderStepped:Connect(function()
local ForceVector = ToWalkRelativeToHRP(Humanoid, Humanoid.MoveDirection, HumanoidRoot)
print(ForceVector)
if ForceVector == "Forwards" then
MainWalk.AnimationId = WalkF.AnimationId
print(MainWalk.AnimationId)
elseif ForceVector == "Backwards" then
MainWalk.AnimationId = WalkB.AnimationId
print(MainWalk.AnimationId)
elseif ForceVector == "Right" then
MainWalk.AnimationId = WalkR.AnimationId
print(MainWalk.AnimationId)
elseif ForceVector == "Left" then
MainWalk.AnimationId = WalkL.AnimationId
print(MainWalk.AnimationId)
end
end)
The setup of the Animations script in Explorer
TL;DR - The walking animations won’t play, but will stay as a still animation (no movement), the script changes walking id yet still dont play dispite being animated