Reoccuring issue with my combat

Currently, I have a working system of combat, after a long long time of debugging and scripting evolution, but the biggest issue I’m dealing with is just one I can’t put my finger on.

See, everytime I have a return in my script, and the return is true, the script will never trigger again. I will show an example-

Combat.OnServerEvent:Connect(function(Player, Count)
	-- removed Count = 0
	local Character = Player.Character
	local Humanoid = Character.Humanoid
	local Humrp = Character.HumanoidRootPart

	if Character:GetAttribute("IsBlocking") == true then
		return
	end


	if Character.Effects:FindFirstChild("Stun") then
		return
	end
	
	if Character:GetAttribute("Training") == true then
		return
	end

	if not Character.Effects:FindFirstChild("Stun") then
		

		Character:SetAttribute("CanAttack", true)


		local Action, Length = CM.getAnimation(Humanoid, Count)

		Action:Play()
		CM.NormalCombat(Player, Character, 5, "Fists", Count, Length)
		print(Count)


		wait(Length)


	--[[==[local KeyList = {}
	for key, value in pairs(Key) do
		table.insert(KeyList, key)
	end
 
	if not Character:FindFirstChild("Stun") then
		if Humanoid:FindFirstChild("Clashing").Value == true then
			print("It works")
			print(Key[KeyList[math.random(#KeyList)])
			Clashin:FireClient(Player, "Clashing")
			CM.Clashing(Player, Character, Humrp, Key)
			
		end
	end
	]]--

		if Count < 4 then
			Combat:FireClient(Player, false)
			Character:SetAttribute("CanAttack", false)	
		else
			Combat:FireClient(Player, true)
			Character:SetAttribute("CanAttack", false)

			--print(_G.CanAttack.Value)
		end
	else
		Combat:FireClient(Player, false) --Resets their cooldowns
		Character:SetAttribute("CanAttack", false)
		--WERK:Disconnect()


	end

end)

E.G

holy heck that looks amazing :smiley:

2 Likes

But anyways, you might have to contact a good scripter. I cannot help you with this right now.

1 Like

It looks like the Stun attribute isn’t bein set back to false after being hit, but I can’t tell without also having the script the enemy is using to attack.

I’m decent at scripting, and even I cannot figure out what is going on. What I would do though is figuring out what return statement is causing the script to forcefully stop execution.

I have a similar problem that I’ll make a post about later. I’ve continually fixed it throughout the years, but it’s with the Defender NPC in “a game”.

local RS = game:GetService("ReplicatedStorage")

local Players = game:GetService("Players")

local SSS = game:GetService("ServerScriptService")

local Combat = require(SSS.RemadeCombat.RemadeCombat)


local Deb = {}
local Count = 1

local RunService = game:GetService("RunService")

while true do
	
	local Action, Length = Combat.getAnimation(script.Parent.Humanoid, Count)

	Action:Play()
	Combat.DummyCombat(script.Parent, 5, "", Count, Length)
	Count += 1
	wait(Length)
	
	
	if Count == 5 then
		Count = 1
		
	end
end

The whole thing is that Stun is rather a value that gets added and destroyed, and I constantly check the effects folder for that, so that doesn’t seem to be the case of right now. Dummy combat is normal combat, but utlized for, well a dummy.

Well, previously I had print statements, and it was during stun if I tried to punch, it’d give me the issue. Then if I tried attacking again, it just wouldn’t work. I might have to look into the local script as well, but I feel like it’s primarily the server script.

EDIT:
After this, I checked out if my print statements in the local script were working… They weren’t.