I have a sword tool that contains two scripts, one named "swordAnimations" and the other "whenEquipped". Currently, I'm trying to have a tool idle animation play when standing still and a tool walk animation to play when the latter happens, but the default ROBLOX animations still play. The "whenEquipped" script is working fine, but the "swordAnimations" script is what I'm concerned with.
There are currently no errors in the output bar when testing this.
"swordAnimations" script:
---VARIABLES--- character = script.Parent.Parent humanoid = script.Parent.Parent:FindFirstChild("Humanoid") sword_idle = humanoid:LoadAnimation(script.sword_idle) sword_walk = humanoid:LoadAnimation(script.sword_walk) ---FUNCTIONS--- local function swordAnimations() local state = humanoid:GetState() if character.Torso.Velocity < 5 then --If player is standing still local ActiveTracks = humanoid:GetPlayingAnimationTracks() for _,v in pairs(ActiveTracks) do --Stop all playing animations v:Stop() end sword_idle:Play() print("sword idle play") elseif state == Enum.HumanoidStateType.Running then --If player is walking/running local ActiveTracks = humanoid:GetPlayingAnimationTracks() for _,v in pairs(ActiveTracks) do v:Stop() end sword_walk:Play() print("sword walk play") end end ---FUNCTION CALLING--- character.Torso:GetPropertyChangedSignal("Velocity"):Connect(swordAnimations)
"whenEquipped" script:
---VARIABLES--- animationsPlaying = script.Parent.swordAnimations ---FUNCTIONS--- animationsPlaying.Disabled = true local function onEquip() animationsPlaying.Disabled = false print("equipped") end local function onUnequip() animationsPlaying.Disabled = true print("unequipped") end ---FUNCTION CALLING--- script.Parent.Equipped:Connect(onEquip) script.Parent.Unequipped:Connect(onUnequip)
Any help or inquiries would be greatly appreciated!