, I’m having an issue with changing animations while the game is running. Essentially the character has access to a sword that has specific walk/idle animations different from the default (unequipped ones).
To achieve this, i’ve been trying to understand how the default Animate script works, I tried doing the following:
local equipped = StatusValues:WaitForChild("Equipped")
local weapon = StatusValues:WaitForChild("Weapon")
equipped.Changed:Connect(function()
if equipped.Value == true then
local weapon = weapon.Value
print('equipping')
if weapon == 'Sword' then
-- change all of the animations for the weapon
Humanoid:ChangeState(Enum.HumanoidStateType.Landed)
script.walk.WalkAnim.AnimationId = "rbxassetid://11127893102"
end
elseif equipped.Value == false then
-- set all the animations back 2 default
print('dequipping')
Humanoid:ChangeState(Enum.HumanoidStateType.Landed)
script.walk.WalkAnim.AnimationId = "rbxassetid://10383236638"
end
end)
Where StatusValues is a folder inside the character (in the workspace) which contains a bunch of BoolValues and StringValues pertaining to gameplay. I set the HumanoidStateType so the animations will instantly update, but importantly: doing this, as in changing the statetype to Landed so the animations will update, has no effect on the described bug following.
This causes an issue, something about directly changing the values of the children of the Animate script causes the character to sometimes stop, but keep playing the walk animation.
Making note that this bug only occurs as seen to other players, the client from where this is occuring only sees the idle animation.
Changing the animationID of the Animate script children seems to be what causes this walk issue. What is the way I should change these animations to fix this issue?