Why does it not count workspace as an ancestor of my humanoid?

I keep getting an AnimationProviderService error and it acts as if my humanoid isn’t a member of the workspace.

if workspace:IsAncestorOf(Humanoid) then
			local Animation = Animator:LoadAnimation(M1Animations[Combo])
			Animation:Play()
		end

This script works good the first time my character loads in and even after I die a couple times but every once in a while it will stop playing animations (after a respawn) as if my humanoid is not considered a part of the workspace. Any help? (THIS IS KILLING ME)

You use LoadAnimation every time you use Play

You should only use LoadAnimation when your player is loaded and then play it afterwards.

Otherwise, you will get an error in the console about the maximum limit of animation usage, and your animation will not be reproduced

1 Like

Ive tried defining the animation outside of the function (which would make it load the animation only once) and I still get the same animationproviderservice error

The Humanoid variable may not be updating then. Where did you put the script?
In other words, I’m thinking that the Humanoid variable would still be referencing the old one you had before you died, that’s why it thinks the humanoid isn’t in workspace anymore.

Сould you send me the script along with where you want to upload the animation, I think that way I can help you out.

Oh yeah, I think that would be the solution.
Since he indicated that after respawning, his animation doesn’t play.

I checked this too but the script works properly for a couple deaths and then stop working after a random amount of respawns. (its very odd)

Here is the full script

local Tool = script.Parent.Parent
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:wait()
local Humanoid = Character:WaitForChild("Humanoid")
local PlayerInfo = Character:FindFirstChild("PlayerInfo")
local PlayerCFrame = Character.HumanoidRootPart.CFrame
local AttackRemote = game.ReplicatedStorage.Remotes.AttackEvent
local VFXRemote = game.ReplicatedStorage.Remotes.VFXRemote
local UIS = game:GetService("UserInputService")
local ActionRemote = game.ReplicatedStorage.WeaponRemotes[Tool.Name].ActionRemote
local Animator = Character:WaitForChild("Humanoid").Animator


--Information
local Damage = 5
local WeaponName = "ISOH"
local M1CD = .3
local ResetTime = 1.3
local M1Count = 5  -- Will break script if set to a number higher than prepared animations
local StringCD = 1.7

local HBVisual = false
local Hitbox = {
	["X"] = 4,
	["Y"] = 6,
	["Z"] = 4
}
local HBoffset = {
	["X"] = 0,
	["Y"] = 0,
	["Z"] = 3  -- The one that matters: Should be Hitbox Z offset/2 + 1
}
local BlackFlash = false
------//// VFX Settings
local VFXTable = {
	["M1VFX"] = game.ReplicatedStorage.VFX[Tool.Name].M1
}
------------//////////
local M1Animations = game.ReplicatedStorage.Animations.Weapons.ISOH.M1


---
local LastM1Time = 0
local Combo = 1
local M1Reset = 0



--
ActionRemote.OnClientEvent:Connect(function(data)
	if Character:WaitForChild("Humanoid"):GetAttribute("Dead") == true then return end
	print(5)
	if tick() - LastM1Time > M1CD and Combo <= M1Count and tick() - M1Reset > StringCD  then
	local BlackFlash = false
	LastM1Time = tick()
	local HitPlayers = {}		
print(6)
	local HitObjects = workspace:GetPartBoundsInBox(Character.HumanoidRootPart.CFrame * CFrame.new(HBoffset.X,HBoffset.Y,-HBoffset.Z), Vector3.new(Hitbox.X,Hitbox.Y,Hitbox.Z))
	for i, v in HitObjects do
		if v.Parent:FindFirstChild("Humanoid") and table.find(HitPlayers, v.Parent) == nil and v.parent.Name ~= Character.Name then 
			table.insert(HitPlayers, v.Parent)
		end
	end

	local BFvalue = math.random(1,100)
	if BFvalue >= 95 then
		BlackFlash = true
	end

	--HITBOX VISUALS
	if HBVisual == true then 
		local Visual = Instance.new("Part")
		Visual.Color = Color3.new(1, 0, 0.0156863)
		Visual.Transparency = .5
		Visual.CFrame = Character.HumanoidRootPart.CFrame * CFrame.new(HBoffset.X,HBoffset.Y,-HBoffset.Z)
		Visual.Size = Vector3.new(Hitbox.X,Hitbox.Y,Hitbox.Z)
		Visual.Anchored = true
		Visual.CanCollide = false
		Visual.CanQuery = false
		Visual.CanTouch = false
		Visual.CastShadow = false
		Visual.Material = Enum.Material.ForceField
		Visual.Parent = workspace
		Visual.Name = "Visual"
		game.Debris:AddItem(Visual,.5)
	end
	local data = {
		["Damage"] = Damage,
		["AttackingPlayer"] = Character,
		["HitPlayers"] = HitPlayers,
		["Blackflash"] = BlackFlash,
		["Action"] = "M1",
		["Weapon"] = WeaponName,
		["HasVFX"] = true,
		["VFX"] = VFXTable.M1VFX,
		["DeleteTime"] = VFXTable.M1VFX:GetAttribute("DeleteTime"),
		["HBoffset"] = HBoffset,
		["VFXPosition"] = "Hitbox",
		["OtherEffect"] = nil
	}

	if #data.HitPlayers == 0  then data.Blackflash = false end

	--Animations for m1
		if workspace:IsAncestorOf(Humanoid) then
			local Animation = Animator:LoadAnimation(M1Animations[Combo])
			Animation:Play()
		end
	--

	if Combo < M1Count then
		Combo += 1
	elseif Combo == M1Count then
		Combo = 1
		M1Reset = tick()
	end
	print(7)
	AttackRemote:FireServer(data)
	end
end)

The prints were for debugging. I either get the animationproviderservice error or it doesn’t identify the humanoid in the “workspace:IsAncestorOf(Humanoid)” part.

Again, the reason I’m struggling with this is it only happens after MULTIPLE deaths and in main game. I can’t recreate the bug in studio

1 Like

Where I wrote 1,2,3,4.
Specify the name of the animations for m1

local Tool = script.Parent.Parent
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:wait()
local Humanoid = Character:WaitForChild("Humanoid")
local PlayerInfo = Character:FindFirstChild("PlayerInfo")
local PlayerCFrame = Character.HumanoidRootPart.CFrame
local AttackRemote = game.ReplicatedStorage.Remotes.AttackEvent
local VFXRemote = game.ReplicatedStorage.Remotes.VFXRemote
local UIS = game:GetService("UserInputService")
local ActionRemote = game.ReplicatedStorage.WeaponRemotes[Tool.Name].ActionRemote
local Animator = Character:WaitForChild("Humanoid").Animator


--Information
local Damage = 5
local WeaponName = "ISOH"
local M1CD = .3
local ResetTime = 1.3
local M1Count = 5  -- Will break script if set to a number higher than prepared animations
local StringCD = 1.7

local HBVisual = false
local Hitbox = {
	["X"] = 4,
	["Y"] = 6,
	["Z"] = 4
}
local HBoffset = {
	["X"] = 0,
	["Y"] = 0,
	["Z"] = 3  -- The one that matters: Should be Hitbox Z offset/2 + 1
}
local BlackFlash = false
------//// VFX Settings
local VFXTable = {
	["M1VFX"] = game.ReplicatedStorage.VFX[Tool.Name].M1
}
------------//////////
local M1Animations = game.ReplicatedStorage.Animations.Weapons.ISOH.M1


---
local LastM1Time = 0
local Combo = 1
local M1Reset = 0

local M1Anims = {
	
	["LMB1"] = Humanoid:LoadAnimation(M1Animations:FindFirstChild(1)),
	["LMB2"] = Humanoid:LoadAnimation(M1Animations:FindFirstChild(2)),
	["LMB3"] = Humanoid:LoadAnimation(M1Animations:FindFirstChild(3)),
	["LMB4"] = Humanoid:LoadAnimation(M1Animations:FindFirstChild(4)),
	
}

--
ActionRemote.OnClientEvent:Connect(function(data)
	if Character:WaitForChild("Humanoid"):GetAttribute("Dead") == true then return end
	print(5)
	if tick() - LastM1Time > M1CD and Combo <= M1Count and tick() - M1Reset > StringCD  then
		local BlackFlash = false
		LastM1Time = tick()
		local HitPlayers = {}		
		print(6)
		local HitObjects = workspace:GetPartBoundsInBox(Character.HumanoidRootPart.CFrame * CFrame.new(HBoffset.X,HBoffset.Y,-HBoffset.Z), Vector3.new(Hitbox.X,Hitbox.Y,Hitbox.Z))
		for i, v in HitObjects do
			if v.Parent:FindFirstChild("Humanoid") and table.find(HitPlayers, v.Parent) == nil and v.parent.Name ~= Character.Name then 
				table.insert(HitPlayers, v.Parent)
			end
		end

		local BFvalue = math.random(1,100)
		if BFvalue >= 95 then
			BlackFlash = true
		end

		--HITBOX VISUALS
		if HBVisual == true then 
			local Visual = Instance.new("Part")
			Visual.Color = Color3.new(1, 0, 0.0156863)
			Visual.Transparency = .5
			Visual.CFrame = Character.HumanoidRootPart.CFrame * CFrame.new(HBoffset.X,HBoffset.Y,-HBoffset.Z)
			Visual.Size = Vector3.new(Hitbox.X,Hitbox.Y,Hitbox.Z)
			Visual.Anchored = true
			Visual.CanCollide = false
			Visual.CanQuery = false
			Visual.CanTouch = false
			Visual.CastShadow = false
			Visual.Material = Enum.Material.ForceField
			Visual.Parent = workspace
			Visual.Name = "Visual"
			game.Debris:AddItem(Visual,.5)
		end
		local data = {
			["Damage"] = Damage,
			["AttackingPlayer"] = Character,
			["HitPlayers"] = HitPlayers,
			["Blackflash"] = BlackFlash,
			["Action"] = "M1",
			["Weapon"] = WeaponName,
			["HasVFX"] = true,
			["VFX"] = VFXTable.M1VFX,
			["DeleteTime"] = VFXTable.M1VFX:GetAttribute("DeleteTime"),
			["HBoffset"] = HBoffset,
			["VFXPosition"] = "Hitbox",
			["OtherEffect"] = nil
		}

		if #data.HitPlayers == 0  then data.Blackflash = false end
		
		local CurrentLMB = "LMB"..Combo
		M1Anims[CurrentLMB]:Play()
		
		if Combo < M1Count then
			Combo += 1
		elseif Combo == M1Count then
			Combo = 1
			M1Reset = tick()
		end
		print(7)
		AttackRemote:FireServer(data)
	end
end)
1 Like

I haven’t tested it and don’t know if it works or not.
Because I don’t have access to your game

1 Like

I’ll check it out when I get home but what exactly does this change?

1 Like

I made the animations play correctly.
So that animations are loaded directly to Humanoid, and played depending on Combo Value

1 Like

Works the same. The script works as intended until I die a few times then gives me the error “Cannot load the AnimationClipProvider Service” on the lines

local M1Anims = {

	["LMB1"] = Humanoid:LoadAnimation(M1Animations:FindFirstChild("1")),
	["LMB2"] = Humanoid:LoadAnimation(M1Animations:FindFirstChild("2")),
	["LMB3"] = Humanoid:LoadAnimation(M1Animations:FindFirstChild("3")),
	["LMB4"] = Humanoid:LoadAnimation(M1Animations:FindFirstChild("4")),
	["LMB5"] = Humanoid:LoadAnimation(M1Animations:FindFirstChild("5")),
}

Starting at the first animation

1 Like

Maybe other scripts are getting in the way, I don’t know
Or try writing after line 4:

repeat wait(0.1)
until Character:FindFirstChild("Humanoid")
2 Likes

Tried waitng as well still doesnt change anything. This bug is really annoying

I seriously don’t know why you have this, maybe it’s a bug in other scripts, or maybe other scripts are interfering with the playback of this script.

Try checking other scripts that are related to Humanoid, or to animations that are located in the path:
local M1Animations = game.ReplicatedStorage.Animations.Weapons.ISOH.M1

1 Like

I tried that yesterday. This is the only script in the experience that deals with animations and I made sure the humanoid is determined entirely within that script. The script is parented to a folder which is inside a tool. (which is then inside the players) but I just don’t know why it has this bug