As you can see my code only loads the sword swing animation ONCE. Also, I don't think the disabling of the different animation scripts is it because I get this error when I swing the sword too many times.
I got this error: "AnimationTrack limit of 256 tracks for one Animator exceeded, new animations will not be played. (x322)"
local Plr = game.Players.LocalPlayer
Plr.CharacterAdded:Wait()
local A1 = game.ReplicatedStorage.Animate:Clone()
local A2 = Plr.Character:WaitForChild("Animate")
A1.Parent = Plr.Character
local E = Plr.Character:WaitForChild("SwordT")
local U = Plr.Character:WaitForChild("SwordF")
local Anim = Instance.new("Animation")
Anim.AnimationId = 'rbxassetid://7306114415'
local Hum = Plr.Character:WaitForChild("Humanoid")
local Swing = Hum:LoadAnimation(Anim)
local HeadshotId = "595183327"
local BodyshotId = "7171761940"
script.Parent.Equipped:Connect(function()
A1.Disabled = false
A2.Disabled = true
E:FireServer(script.Parent.Attatch)
end)
script.Parent.Unequipped:Connect(function()
A1.Disabled = true
A2.Disabled = false
U:FireServer()
end)
script.Parent.Activated:Connect(function()
Swing:Stop()
Swing:Play()
local I = false
script.Parent.Blade.Touched:Connect(function(hit)
if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") and hit.Parent ~= Plr.Character and I == false and Swing.IsPlaying then
I = true
game.ReplicatedStorage.DO:FireServer(hit)
local G = game.ReplicatedStorage.HitGui:Clone()
G.Parent = game.Workspace
G.Position = hit.Position
G.BillboardGui.TextLabel.Text = "-23"
if hit.Name == "Head" then
G.BillboardGui.TextLabel.Text = "-75"
end
wait(0.5)
G:Destroy()
end
end)
wait(Swing.Length)
Plr.Character:WaitForChild("Humanoid"):UnequipTools()
Plr.Character:WaitForChild("Humanoid"):EquipTool(script.Parent)
end)
