Messy Bow causing a lot of warnings

Hi, I altered a script I found from a bow tutorial in youtube and it worked well except the fact that it was very very messy.

I added things like animations, force shiftlock and I implemented the hitbox module.

I usually don’t ignore the messy-ness but this time I couldn’t ignore it no matter what because it was affecting the animations.

There was a warning that I usually never get:

Animationtrack limit of 256 tracks for one animator exceeded, new animations will not be played

So here’s the question, is there any way to clean this in a way it doesn’t warn anymore.

Thank you for reading and your help :smile:

This bow uses 2 scripts, local script and global script

Local Script

local tool = script.Parent
local mouse = game.Players.LocalPlayer:GetMouse()
local buttonDown = false

local BowAnimations = game:GetService("ReplicatedStorage").ClientAnimations.Archer.Bow
local Humanoid = game.Players.LocalPlayer.Character:WaitForChild("Humanoid")
local Root = game.Players.LocalPlayer.Character.HumanoidRootPart

function shiftLock(active) --Toggle shift.lock function
	if active then		
		Humanoid.CameraOffset = Vector3.new(1.75,0,0) -- I assume this is about the right camera offset.
		Humanoid.AutoRotate = false --Disable the automatic rotation since we are the ones setting it.

		game:GetService("RunService"):BindToRenderStep("ShiftLock", Enum.RenderPriority.Character.Value, function()
			game:GetService("UserInputService").MouseBehavior = Enum.MouseBehavior.LockCenter --Set the mouse to center every frame.

			local _, y = workspace.CurrentCamera.CFrame.Rotation:ToEulerAnglesYXZ() --Get the angles of the camera
			Root.CFrame = CFrame.new(Root.Position) * CFrame.Angles(0,y,0) --Set the root part to the camera's rotation
		end) 
	else
		Humanoid.AutoRotate = true --Let the humanoid handle the camera rotations again.
		Humanoid.CameraOffset = Vector3.new(0,0,0) --Move the camera back to normal.
		game:GetService("RunService"):UnbindFromRenderStep("ShiftLock") -- Allow mouse to move freely.
		game:GetService("UserInputService").MouseBehavior = Enum.MouseBehavior.Default -- Let the mouse move freely
	end
end


tool.Activated:Connect(function()
	shiftLock(true)
	Zoom = game:GetService("TweenService"):Create(game.Workspace.CurrentCamera, TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut) , {FieldOfView = 40})
	Zoom:Play()
	buttonDown = true
	Draw = Humanoid:LoadAnimation(BowAnimations.Draw)
	DrawLoop = Humanoid:LoadAnimation(BowAnimations.DrawLoop)
	Fire =Humanoid:LoadAnimation(BowAnimations.Fire)
	Draw:Play()
	DrawLoop:Play()
end)

tool.Deactivated:Connect(function()
	script.Parent.BowEvent:FireServer("shoot", script.Parent.Bow.Middle.Position.Z, mouse.Hit)
	local Normal = game:GetService("TweenService"):Create(game.Workspace.CurrentCamera, TweenInfo.new(0.35, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut) , {FieldOfView = 70})
	Zoom:Pause()
	Normal:Play()
	Draw:Stop()
	DrawLoop:Stop()
	Fire:Play()
	shiftLock(false)
	buttonDown = false
end)

tool.Equipped:Connect(function()
	Idle = Humanoid:LoadAnimation(BowAnimations.Idle)
	Idle.Priority = Enum.AnimationPriority.Idle
	Idle:Play()
end)


tool.Unequipped:Connect(function()
	Idle:Stop()
end)

game:GetService("RunService").RenderStepped:Connect(function()
	if tool.Parent:FindFirstChild("Humanoid") then
		if buttonDown then
			script.Parent.Bow.Middle.Position = script.Parent.Bow.Middle.Position:Lerp(Vector3.new(0, 0, 1.998), 0.1)

		else	
			script.Parent.Bow.Middle.Position = script.Parent.Bow.Middle.Position:Lerp(Vector3.new(0, 0, 0.637), 0.7)
		end

		script.Parent.Bow.Weld.C1 = CFrame.new(-Vector3.new(0, 0, script.Parent.Bow.Middle.Position.Z - 0.7))
	end
end)


script.Parent.BowEvent.OnClientEvent:Connect(function(arrow, charge)
	
	arrow:Destroy()
	
	local newArrow = script.Parent.Arrow:Clone()
	newArrow.Parent = workspace
	
	local Position = Vector3.new(newArrow.Position.X,newArrow.Position.Y+3,newArrow.Position.Z)
	newArrow.Transparency = 0
	newArrow.CFrame = CFrame.new(Position, mouse.Hit.Position)

	newArrow.Velocity = mouse.Hit.LookVector * charge * 200
	
	
	newArrow.Touched:Connect(function(hit)

		if hit.Parent ~= game.Players.LocalPlayer.Character and hit.Parent.Parent ~= game.Players.LocalPlayer.Character then

			newArrow:Destroy()
		end
	end)
end)


while wait(0.1) do
	
	script.Parent.BowEvent:FireServer("string", script.Parent.Bow.Middle.Position, script.Parent.Bow.Weld.C1)
end

Script

local Tool = script.Parent
local Handle = Tool.Handle
local Bow = Tool.Bow

local Debris = game:GetService("Debris")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local CastFolder = ReplicatedStorage.Modules.Cast
local ClientCast = require(CastFolder.ClientCast)
local RaycastHitbox = require(CastFolder.RaycastHitboxV4)

-- Debounce
local Cooldown = false
local Debounce2 = {}

function TagHumanoid(humanoid, player)
	local Creator_Tag = Instance.new("ObjectValue")
	Creator_Tag.Name = "Tagged"
	Creator_Tag.Value = player
	Debris:AddItem(Creator_Tag, 2)
	Creator_Tag.Parent = humanoid
end

function UntagHumanoid(humanoid)
	for i, v in pairs(humanoid:GetChildren()) do
		if v:IsA("ObjectValue") and v.Name == "Tagged" then
			v:Destroy()
		end
	end
end

Tool.BowEvent.OnServerEvent:Connect(function(Player, Instruct, Charge, mHit)
	if Tool.Parent == Player.Character and not Cooldown and Instruct == "shoot" then
		Cooldown = true
		Handle.Shoot:Play()
		local newArrow = script.Parent.Arrow:Clone()
		newArrow.Parent = workspace
		script.Parent.Arrow.Transparency = 1
		local Position = Vector3.new(newArrow.Position.X,newArrow.Position.Y+3,newArrow.Position.Z)
		newArrow.CFrame = CFrame.new(Position, mHit.Position)
		newArrow.Velocity = mHit.LookVector * Charge * 200

		Debris:AddItem(newArrow, 30)
		local touched = false

		
		local Hitbox = RaycastHitbox.new(newArrow)
		Hitbox.Visualizer = true
		Hitbox:HitStart() 
		
		Hitbox.OnHit:Connect(function(RaycastResult, HitHumanoid)
			print("Hit")
			if HitHumanoid and HitHumanoid ~= script.Parent.Parent.Humanoid then	
				if HitHumanoid then
					HitHumanoid:TakeDamage(10)
					local Hit = Handle.Hit:Clone()
					Hit.Parent = Player.Character.HumanoidRootPart
					Hit:Play()
					Debris:AddItem(Hit,2)
				end
			end
		end)

		Tool.BowEvent:FireClient(Player, newArrow, Charge)

		wait(1)
		script.Parent.Arrow.Transparency = 0

		Cooldown = false
	elseif Instruct == "string" then
		Handle.Draw:Play()
		script.Parent.Bow.Middle.Position = Charge
		script.Parent.Bow.Weld.C1 = mHit
	end
end)

Don’t use Humanoid to load animations anymore, it’s deprecated. Instead, use Animator instead. More information can be found here: