When I do the animation in my game for the first time it works fine, but when I stop it and then do the same thing the second time the animation doesnt play at all. The animation is looped.
local rs = game.ReplicatedStorage
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://7329829970"
local pressed = false
rs.Charging.OnServerEvent:Connect(function(player, value)
pressed = true
if player.Skills:FindFirstChild("ManaChargeI") ~= nil then
local char = player.Character
local track = char:WaitForChild("Humanoid"):LoadAnimation(animation)
if value == "IsCharging" then
track:Play()
local FX1 = game.ReplicatedStorage.ManaCharge:clone()
FX1.CFrame = char.HumanoidRootPart.CFrame
FX1.Parent = char
game.Debris:AddItem(FX1,9999999)
char.Humanoid.WalkSpeed = 0
char.Humanoid.JumpPower = 0
while pressed == true and char.Humanoid.Mana.Value < char.Humanoid.MaxMana.Value do
wait(.1)
FX1.CFrame = char.HumanoidRootPart.CFrame
char.Humanoid.Mana.Value += 1
end
elseif value == "IsNotCharging" then
char.Humanoid.WalkSpeed = 16
char.Humanoid.JumpPower = 50
pressed = false
char:FindFirstChild("ManaCharge"):Destroy()
track:Stop()
end
end
end)