Script sometime works and sometime doesn't

Hello guys, today it will be a painfully long topic and I really need some helps.
So currently, I was making a combat system that send signals to play animations at local script (PlayAnimations) and other stuff in server script (Input Response, PlayerStateTracking). I also made another local script that play primary animations (Animate) like : idle, walk, jump, fall.

So here us the problem, whenever the “Animate” Script runs, it will stop the whole combat system. Weirdly enough, the output printed no error. I was tried to run it again a few times and … It worked ?! At first, I thought that was just me making a mistake somewhere, but the more I runs the code without changing it, I realized it will randomly work or not work. It’ll be nice if you can spend a bit of time looking at my problem, thank you!
— “Animate” – Script

local uis = game:GetService("UserInputService")
local Player = game.Players.LocalPlayer
local char = Player.Character or Player.CharacterAdded:Wait()
local humanoid = char:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
local runService = game:GetService("RunService")

local walkAnimation = Instance.new("Animation")
local idleAnimation = Instance.new("Animation")
local jumpAnimation = Instance.new("Animation")
local fallAnimation = Instance.new("Animation")

local animations = script:WaitForChild("Animations")

local function setAnimation ()
	walkAnimation = humanoid:LoadAnimation(animations:FindFirstChild("Walk"))
	walkAnimation.Priority = Enum.AnimationPriority.Core
	walkAnimation.Stopped:Connect(function()
		if humanoid.MoveDirection.Magnitude > 0 then
			walkAnimation:Play()
		end
	end)

	idleAnimation = humanoid:LoadAnimation(animations:FindFirstChild("Idle"))
	idleAnimation.Priority = Enum.AnimationPriority.Idle
	idleAnimation.Stopped:Connect(function()
		if humanoid.MoveDirection.Magnitude == 0 then
			idleAnimation:Play()
		end
	end)
--	jumpAnimation = humanoid:LoadAnimation(animations:FindFirstChild("Jump"))
--	fallAnimation = humanoid:LoadAnimation(animations:FindFirstChild("Fall"))
	
end

setAnimation()

runService.RenderStepped:Connect(function()
	
	
	if humanoid.MoveDirection.Magnitude > 0 and walkAnimation.IsPlaying == false then
		idleAnimation:Stop()
		walkAnimation:Play()
	end
	humanoid.Running:Connect(function(speed)
		if speed == 0 and idleAnimation.IsPlaying == false then
			walkAnimation:Stop()
			idleAnimation:Play()
		end
	end)
	
end)

— “Play Animation” Script —

local RS = game:GetService("ReplicatedStorage")
local Players = game.Players
local clientCast = require(RS.Modules.ClientCast)
local remote = RS.RemoteEvent.PlayAnimations

local function hitboxSetup(address,obj)

	local tab = {}

	for  _,v in pairs(address:GetDescendants()) do
		if v.Name == obj then
			table.insert(tab,v)
		end
	end
	return tab
end


local function enableHitboxes(hitboxesTablel)
	for _,v in pairs(hitboxesTablel) do
		v:Start()
	end
end
local function disableHitboxes(hitboxesTable)
	for _,v in pairs(hitboxesTable) do
		v:Stop()
	end
end


local function playAnimation(combo,attacks,chr,hitboxTable)

	local SUani = Instance.new("Animation")
	local ATani = Instance.new("Animation")
	local ELani = Instance.new("Animation")
	SUani.Parent = RS:WaitForChild("Animations")
	ATani.Parent = RS:WaitForChild("Animations")
	ELani.Parent = RS:WaitForChild("Animations")

	SUani.AnimationId = "rbxassetid://"..tostring(attacks[combo].Startup)
	ATani.AnimationId = "rbxassetid://"..tostring(attacks[combo].Attacking)
	ELani.AnimationId = "rbxassetid://"..tostring(attacks[combo].Endlag)

	local track
	local animator = chr:WaitForChild("Humanoid"):WaitForChild("Animator")
	track = animator:LoadAnimation(SUani)
	track.Looped = false
	track:AdjustWeight(math.huge,0)
	track:Play(0)
	track.Stopped:wait()
	track:Stop(0)
	
	enableHitboxes(hitboxTable)
	track = animator:LoadAnimation(ATani)
	track.Looped = false
	track:AdjustWeight(math.huge,0)
	track:Play(0)
	track.Stopped:wait()
	track:Stop(0)
	disableHitboxes(hitboxTable)
	
	track = animator:LoadAnimation(ELani)
	track.Looped = false
	track:AdjustWeight(math.huge,0)
	track:Play(0)
	track.Stopped:wait()
	track:Stop(0)
end

remote.OnClientEvent:Connect(function(combo,attacks,chr,hitboxtable)
	
	local plr = game:GetService("Players"):GetPlayerFromCharacter(chr)
	
	local address = plr.Character:FindFirstChild("WeldingWeapon")

	local hitboxespart = {}
	local hitboxes = {}
	hitboxespart = hitboxSetup(address,tostring(attacks[combo].HitBoxSource))
	for _,v in pairs(hitboxespart) do 

		local hitbox = clientCast.new(v,RaycastParams.new())
		table.insert(hitboxes,hitbox)
	end

	for _,v in pairs(hitboxes) do
		v:Stop()
	end
	playAnimation(combo,attacks,chr,hitboxes)
	print("3")
	remote.Parent.ReturnAttack:FireServer()
	
end)

— “Input Response” Script —

local Player = game.Players
local RS = game:GetService("ReplicatedStorage")
local RE = RS:WaitForChild("RemoteEvent")
local WP = require(RS.GameDataStorage.Weapons)
local PlayerStats = require(RS.GameDataStorage.PlayerStats)
local clientCast = require(RS.Modules.ClientCast)
local SSS = game:GetService("ServerScriptService")
local LPC = require(SSS.Setup.LocalPlayerStats)

local PlayAnimationRemote = RS.RemoteEvent.PlayAnimations
--Functions :

local function performLMB (ID,combo,plr)
	
	local UID = game:GetService("Players"):GetUserIdFromNameAsync(plr.Name)
	local stat = LPC:GetPlayerStats(UID)
	
	if stat.inBattle == false then
		return
	end
	if stat.Attacking == true then 
		return
	end
	local currentTime = stat.currentTime
	if tick() - currentTime > 1 then
		combo = 1
		stat.currentCombo = 1
	end
	print("2")
	stat.Attacking = true
	local weapon = WP:FindWeaponByID(ID)
	local attacks = WP:GetWeaponAttacks(weapon.Name)
	local char = plr.Character
	PlayAnimationRemote:FireClient(plr,combo,attacks,char)
end

RE.performLMB.OnServerEvent:Connect(function(plr)
	
	local UID = game:GetService("Players"):GetUserIdFromNameAsync(plr.Name)
	local stat = LPC:GetPlayerStats(UID)
	local WID = stat.ID
	
	local combo = stat.currentCombo
	if stat.input == false then return
	end
	print(stat)
	performLMB(WID,combo,plr)
end)

— “PlayerStateTracking” Script —

local SSS = game:GetService("ServerScriptService")
local LPC = require(SSS.Setup.LocalPlayerStats)
local RS = game:GetService("ReplicatedStorage")
local RE = RS.RemoteEvent

RE.performLMB.OnServerEvent:Connect(function(plr)
	local UID = game:GetService("Players"):GetUserIdFromNameAsync(plr.Name)
	local stat = LPC:GetPlayerStats(UID)
	if stat.inBattle == false then 
		return
	end
	if stat.input == true then
		stat.input = false
		local humanoid = plr.Character:FindFirstChild("Humanoid")
		humanoid.WalkSpeed = 0
		humanoid.JumpPower = 0
	end

end)
RE.ReturnAttack.OnServerEvent:Connect(function(plr)
	local UID = game:GetService("Players"):GetUserIdFromNameAsync(plr.Name)
	local stat = LPC:GetPlayerStats(UID)
	if stat.inBattle == false then 
		return
	end
	local delaytime = 0
	if stat.currentCombo == 5 then
		delay(1,function()
			stat.Attacking = false
			stat.input = true
 		end)
	else
		stat.Attacking = false
		stat.input = true
	end
	print("4")
	stat.currentCombo = stat.currentCombo % 5 + 1
	stat.currentTime = tick()
	local humanoid = plr.Character:FindFirstChild("Humanoid")
	humanoid.WalkSpeed = 16
	humanoid.JumpPower = 50
end)

— In case you need, here is the “PlayerStats” module script —

local PlayerStats = {}
PlayerStats.__index = PlayerStats
function PlayerStats:new(userid)
	
	local stat = setmetatable({},self)
	
	stat.ID = 0
	stat.CD = false
	stat.Cash = 0
	stat.Blocking = false
	stat.currentCombo = 1
	stat.UserID = userid
	stat.inBattle = false
	stat.Attacking = false
	stat.currentTime = 0
	stat.input = true
	return stat
	
end

function PlayerStats:update(new_id,CD,cash_amount,is_blocking,current_combo,is_inBatlle,is_Attacking)
	
	self.ID = new_id or self.ID
	self.CD = CD or self.CD
	self.Cash = cash_amount or self.Cash
	self.Blocking = is_blocking or self.Blocking
	self.currentCombo = current_combo or self.currentCombo
	self.inBattle = is_inBatlle or self.inBattle
	self.Attacking = is_Attacking or self.Attacking
	
end

return PlayerStats