Animation no stopped problem

Hello, why my animation is not stopped when the weapon is destroyed ?

local uis = game:GetService("UserInputService")
local p = game:GetService("Players").LocalPlayer

local rs = game:GetService("ReplicatedStorage")

local Equip_ARI = script:WaitForChild("Equip_ARI")

uis.InputBegan:Connect(function(code, _gp)
	if code.KeyCode == Enum.KeyCode.One and not _gp then
		local character = p.Character
		local humanoid = character:FindFirstChild("Humanoid")
		
		local mWeapon = rs.Events.Inventory.GetMainWeapon:InvokeServer()
		if mWeapon == "ARI" then
			local isEquipped = rs.Events.Items.GetARIEquipped:InvokeServer()
			local EquipAnimTrack_ARI = humanoid.Animator:LoadAnimation(Equip_ARI)
			if isEquipped then
				character:FindFirstChild("ARI"):Destroy()
				rs.Events.Items.SetARIEquipped:FireServer(false)
				EquipAnimTrack_ARI:Stop()
			else 
				rs.Events.Items.GiveItem:FireServer("ARI")
				rs.Events.Items.SetARIEquipped:FireServer(true)
				EquipAnimTrack_ARI:Play()
			end
		end
	end
end)

https://gyazo.com/cdf6749371ce9046722f66ed448e5ee7

I used the animator to get the current animations played by the character.

local uis = game:GetService("UserInputService")
local p = game:GetService("Players").LocalPlayer

local rs = game:GetService("ReplicatedStorage")

local Equip_ARI = script:WaitForChild("Equip_ARI")

uis.InputBegan:Connect(function(code, _gp)
	if code.KeyCode == Enum.KeyCode.One and not _gp then
		local character = p.Character
		local humanoid = character:FindFirstChild("Humanoid")
		
		local mWeapon = rs.Events.Inventory.GetMainWeapon:InvokeServer()
		if mWeapon == "ARI" then
			local isEquipped = rs.Events.Items.GetARIEquipped:InvokeServer()
			local EquipAnimTrack_ARI = humanoid.Animator:LoadAnimation(Equip_ARI)
			if isEquipped then
				rs.Events.Items.RemoveItem:FireServer("ARI")
				rs.Events.Items.SetARIEquipped:FireServer(false)
				EquipAnimTrack_ARI:Stop()
				
				local tracks = humanoid:FindFirstChildOfClass("Animator"):GetPlayingAnimationTracks()
				for i,v in pairs(tracks) do 
					if v.Name == "Equip_ARI" then
						v:Stop()
					end
				end
			else 
				rs.Events.Items.GiveItem:FireServer("ARI")
				rs.Events.Items.SetARIEquipped:FireServer(true)
				EquipAnimTrack_ARI:Play()
			end
		end
	end
end)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.