Well. Blocking is weird

Honestly, I been having a huge issue with Block creation, and I made an effort to make a blocking system, but the way of detection is such a pain to me. The biggest issue of what is what I should represent the other humanoid as, or just work around something else.

function CombatHandler.Blocking(Player, Character, ePlayer, Count)
	local Character = Player.Character
	local Hum = Character.Humanoid
	
	local eCharacter = ePlayer.Character
	local eHuman = eCharacter.Humanoid
	
	local Distance = Character.Position.Magnitude - eCharacter.Position.Magnitude
	
	local HitBoxDistance = eCharacter.CFrame - Hitbox.CFrame
	
	local HBD2 = HitBoxDistance:Dot(eHuman.CFrame.LookVector)
	
	
	for _, Players in pairs(LT:GetChildren()) do
		if Character.Position.Magnitude <= Distance and Players.Position.Magnitude and LT ~= Character and Players.Character.Humanoid.Health > 0 then
			if Players.Humanoid:FindFirstChild("IsBlocking") == true then
				if Players.Character.CFrame <= HBD2 then
					Hitbox:Destroy()
					
					if Count == 4 then 
						local GBValue = Instance.new("BoolValue")
						GBValue.Parent = Players.Character.Humanoid
						
						Players.Character.Humanoid.WalkSpeed = 0
						Players.Character.Humanoid.JumpPower = 0
						Debris:AddItem(GBValue, 2)
						Players.Character.Humanoid.WalkSpeed = 16
						Players.Character.Humanoid.JumpPower = 50.125
						
						end
					break
				end
			end
		end
	end
	```
--Here's the script. Only thing that wasn't seen is the hitbox, which is just

Hitbox = Meshes.Hitbox:Clone()
	Hitbox.Parent = Folder
	Hitbox.CFrame = Humrp.CFrame * CFrame.new(0,0,-2)

Honestly, I just want to delete the hitbox from the person who fired the other event, or offset the damage by like 5. The /5 method is a bit foreign to me though so I’m not really willing to make that effort and do that.

Can you show the code calling the function?

Of course.

-- \\ Module-Related Variables // --

local BM = require(script.Parent.CombatHandler.CombatModule)

-- \\ Get-Service Variables // --

local RS = game:GetService("ReplicatedStorage")

-- \\ Events Variables // --

local Block = RS.Block
local Count = 0 -- moved it here

-- \\ Functions // --

Block.OnServerEvent:Connect(function(Player, ePlayer)
	
	local Character = Player.Character
	local eCharacter = ePlayer.Character
	
	local eHuman = eCharacter.Humanoid
	
	BM.Blocking(Player, Character, ePlayer, Count)
	
	
end)

Add print statements.

Block.OnServerEvent:Connect(function(Player, ePlayer)
	
	local Character = Player.Character
	local eCharacter = ePlayer.Character

print(Player, ePlayer)
print(Character, eCharacter)

	local eHuman = eCharacter.Humanoid
	
	BM.Blocking(Player, Character, ePlayer, Count)
	
	
end)


Send the output afterwards

edit: I have to go right now but other developers can help you out.

1 Like

Well, if you do come back or if someone takes over, here’s the printed things.

 16:14:43.795  Player1 Block  -  Server - BlockHandler:21
  16:14:43.796  Player1 nil  -  Server - BlockHandler:22
  16:14:43.802  ServerScriptService.BlockHandler:25: attempt to index nil with 'Humanoid'  -  Server - BlockHandler:25
  16:14:43.803  Stack Begin  -  Studio
  16:14:43.803  Script 'ServerScriptService.BlockHandler', Line 25  -  Studio - BlockHandler:25
  16:14:43.803  Stack End  -  Studio

ah yes. Echaracter is returning nil. Your error is because you are saying nil.Humanoid since the eCharacter is nil.

How ever you are referencing eCharacter must be returning nil

The issue is that I don’t know how would I carry the values over to the Module otherwise, because I have little to no idea on how I would find the enemy humanoid unless I just decided to completely to do the Blocking on the Server Script with no module.

What is the code which fires the remote event?

UIS.InputBegan:Connect(function(Input, IsTyping)
	if Input.KeyCode == Enum.KeyCode.F and Debounce == false then
		if not IsTyping then
			Debounce = true
			ButtonDown = true


			RS.Block:FireServer("Block")	
			
			while ButtonDown == true  do
				wait()
			end		

			
			RS.Release:FireServer("Release")

			wait(.9)
			Debounce = false
		end	
	end
end)

(These paraments are useless I believe, so I’ll be clearing them out. It was for a previous blocking system I tried similar to this one (which failed as well))

Which line is giving the error? It says 21, but I’m unsure if that’s the exact lines or not.

Welcome back to my combat issues.

The error would be right

local eHuman = eCharacter.Humanoid

Where this is.

Are we talking about the actual module?

Seems here that ePlayer is equal to Block

Make sure that the LocalScript firing the Block event correctly sends the ePlayer as a player.

Yes, I see it.

You are sending “Block” as the ePlayer parameter. There is no Character within a string.

Yeah, but even if this is sent how would I really give it a value via the localscript. This variable is meant to be for the closest/enemy player that the character might be facing.

Seems here that you are sending “Block” to the event, which is then set to ePlayer

In your event receiver, you try to index the string “Block” and get the Character, as if it is a Player.

In that above snippet, ePlayer is equal to "Block" and therefore does not have a Character.

Oh. So, I cannot send anything over.

You need to send the player that you are trying to Block (ePlayer)

How would I do that from the local script and detect the enemy Player. Or maybe I’m misunderstanding.

Please correct me if I’m wrong, but you want me to send over the ePlayer as the already existing Player to represent the enemy? Or rather me create a detection script to see who’s close and send whoever is found over to the server script?

You’d need to do that, since that is what you’re trying to do.
I am unsure what you are trying to achieve currently so I cannot give you many details regarding that.

I’ll kind of break down the basic thing I made an effort to do.

• Begin to do anims all that small stuff

• Check if you are blocking

• Check if someone is near you and is attacking

• If they aren’t behind you destroy their hitbox so they cannot do damage

• If they reached Count == 4 then it’ll break this block, and begin to give you a guard broken value so you can take damage once more.

My whole thing about this is that an exploiter might be able to mess around with this no?