So I have a script that changes the walk speed and animation depending on the direction the character is facing. But the animation wouldn’t update until I stopped moving. For example I’m walking while holding W, then I switch to hold A while holding W, the animation is the the one for W not the for A. But if I stop holding W before switching A it would update. The walkspeed updates fine so I’m here to seek help, I am a new scripter and this my first time posting the devforum. Heres the script
local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer
local character = script.Parent
local Humanoid = character:WaitForChild("Humanoid")
local HumanoidRootPart = character:WaitForChild("HumanoidRootPart")
local runanim =script.Parent.Animate.walk.WalkAnim
-- Wait for PlayerScripts and necessary modules to load
local playerScripts = LocalPlayer:WaitForChild("PlayerScripts")
local playerModule = playerScripts:WaitForChild("PlayerModule")
local controlModule = require(playerModule):GetControls() -- Use GetControls() which returns the active ControlModule
while task.wait() do
local moveVector = controlModule:GetMoveVector()
if moveVector.Z < 0 then
Humanoid.WalkSpeed = 16
runanim.AnimationId = "rbxassetid://139317481490265"
else
Humanoid.WalkSpeed = 10
runanim.AnimationId = "rbxassetid://89491080922343"
end
end