Tool Animations stop working on reset

Basically, I have an issue where whenever I reset I get the error
Cannot load the AnimationClipProvider Service
The main reason I am confused is because it only happens after I reset, not when I start in the game
why could this be
(local script where animations are played)

local plr = game.Players.LocalPlayer or game.Players.PlayerAdded:Wait()
local char = plr.Character or plr.CharacterAdded:Wait()
game:GetService('RunService').Stepped:Wait()
local hum = char:WaitForChild("Humanoid", math.huge)
local animator = hum:WaitForChild("Animator")
local idle
local attack
local db = false
pcall(function()
	game:GetService("RunService").Stepped:Wait()
	attack = animator:LoadAnimation(script:WaitForChild("Attack"))
	idle = animator:LoadAnimation(script:WaitForChild("Idle"))
end)
local raycast = require(game.ReplicatedStorage.RaycastHitboxV4)
local box = raycast.new(script.Parent:WaitForChild("Handle", math.huge))
script.Parent.Equipped:Connect(function()
	if idle then
		idle:Play()
	end
end)
script.Parent.Unequipped:Connect(function()
	if idle then
		idle = animator:LoadAnimation(script:WaitForChild("Idle"))
	end
	idle:Stop()
end)
script.Parent.Activated:Connect(function()
	if db then return end
	db = true
	box:HitStart()
	if attack then
		attack:Play()
	end
	wait(0.3333333432674408)
	box:HitStop()
	wait(1.15)
	db = false
end)
box.OnHit:Connect(function(hit, humanoid)
	if hit.Parent:FindFirstChild("Boss") then
		script.Parent.Strike:FireServer(humanoid, hit.Parent.Values)
	end
end)
hum.Died:Connect(function()
	animator = nil
	idle = nil
	attack = nil
	script.Parent:Destroy()
end)

server-side just in case

local damage = 10
script.Parent.Strike.OnServerEvent:Connect(function(plr, hum, values)
	if not values.Invincible.Value then
		if values.Parry.Value then
			hum:TakeDamage(damage*values.BaseDamageMultiplier.Value)
			plr.Character.Humanoid.Health+=10
		else
			hum:TakeDamage(damage)
		end
	end
end)

Happens whenever you try to load an animation with a character that isn’t in workspace. Just add task.wait() before you define the character in your local script and you should be fine.

ill try that thank you so much i can now add me, my cousin, and some of his friends as bosses this is so amazing (ill add this as the oslution if it works)
also should i use task.wait or wait for stuff since you mentioned that i dunno the difference lol

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