Why isn't this statement printing?

local Key = {

	K = Enum.KeyCode.K,
	
	F = Enum.KeyCode.F,
	
	C = Enum.KeyCode.C,
	
	Z = Enum.KeyCode.Z,
	
	T = Enum.KeyCode.T,
	
	Y = Enum.KeyCode.Y,
	
	P = Enum.KeyCode.P,
	
	O = Enum.KeyCode.O,
	
	E = Enum.KeyCode.E,
}


-- \\ Functions // --

Combat.OnServerEvent:Connect(function(Player)
	-- removed Count = 0
	local Character = Player.Character
	local Humanoid = Character.Humanoid
	local Humrp = Character.HumanoidRootPart
	
	if _G.CanAttack == false and _G.Blocking == true then
		return
	end
	

	if Character:FindFirstChild("Stun") then return end
	
	if not Character:FindFirstChild("Stun") then
		local ClashCount = math.random(1, 60)
		
		_G.CanAttack.Value = true
		_G.ClashChance.Value = ClashCount
		print(_G.ClashChance.Value)
			print("WERKKKK")
			Count += 1
			CM.CombatStarted(Player, Character, Humrp, Count)
			print(Count)
		_G.CanAttack.Value = false
		_G.ClashChance.Value = nil
		if Count == 4 then
			Count = 0
		end
	end
	
	local KeyList = {}
	for key, value in pairs(Key) do
		table.insert(KeyList, key)
	end
 
	if not Character:FindFirstChild("Stun") then
		if Character.Humanoid:FindFirstChild("Clashing").Value == true then
			print("It works")
			print(Key[KeyList[math.random(#KeyList)]])
			Combat:FireClient("Clashing")
			CM.Clashing(Player, Character, Humrp, Key)
			
		end
	end

end)

Basically, I give my character the value to do Clashing and place it to true only for it never to print that.

1 Like

Are there any errors?

Have you tried adding print statements to these to check if it’s returning before doing anything?

1 Like

There are errors, but it’s after those two are checked, not before.

Then what are the errors? It matters if it’s in the same script.

It’s more for the already working Combat script. The error being this,

This is within the module by the way.

That error occurs because the script still ran after the character left the game (not the player). This is a module script so that does happen. Notice how this error never occurs when you are playing but occurs when you stop running the game.

Oh, no it’ll happen when the character is still actively there. After doing a little test it won’t actually happen.

if Character.Humanoid:FindFirstChild("Clashing").Value == true then

You already have a reference to the character’s humanoid via the variable “Humanoid”, there’s no need to index the character for its humanoid instance here.

Did my own personal test. Apparently, the thing was working the whole time I was just a little dumb.


(The error is something recently added I’ll fix it later.)