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)
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.
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
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)
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
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
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