How would I make the Enemy Character accessible and known by the script?

Currently I am trying to make a block system but when I try to use it, it’ll say that error. Currently I’m trying make it acknowledge the existence of an Enemy HRP, and if it does work, it’s meant to the damage /5.

local SSS = game:GetService("ServerScriptService")

local Dic = require(SSS:WaitForChild("DictonaryHandler"))

local CTHandler = require(SSS.CombatSent:WaitForChild("CombatHandler"))

local DMG = workspace:WaitForChild("BaseDamage")

local baseDmgVal = DMG.Value

local Players = game:GetService("Players")

local Blocking = Players:GetAttribute("Blocking")

local BlockHandler = {}

function BlockHandler:OffSetDamage(Character, Enemy, combo, damage)

	local Humrp = Character.HumanoidRootPart

	local eHumRP = Enemy.HumanoidRootPart
	local vector = eHumRP.Position - Humrp.Position
	local CharDot = vector:Dot(Humrp.CFrame.lookVector)
	local EnemyDot = vector:Dot(eHumRP.CFrame.lookVector)
	if CharDot > 0 and EnemyDot > 0 then
		if not Dic.find(Character, "Stunned") or Blocking == false then

return BlockHandler

What arguments are you sending to the OffsetDamage function?

prior, it was just Character and Enemy, but I don’t know how to get the Enemy from the serverscript. The Combo and Damage script have been deleted because I noticed I didn’t really need it.

Could you show the script firing this function.

local UIS = game:GetService("UserInputService")

local RS = game:GetService("ReplicatedStorage")

local SSS = game:GetService("ServerScriptService")

local Block = RS.Block

local CTHandler = require(SSS.CombatSent.CombatHandler)

local BlockHandler = require(script.BlockHandler)

local DicHandler = require(SSS:WaitForChild("DictonaryHandler"))

local Players = game:GetService("Players")

Block.OnServerEvent:Connect(function(Player, Enemy)
	local Character = Player.Character
	local Humanoid = Character.Humanoid
	local HumRP = Character.HumanoidRootPart
	local IsBlocking = Character:FindFirstChild("IsBlocking")
	IsBlocking.Value = true

	if not DicHandler.find(Character, "Stunned") or Character:FindFirstChild("IsBlocking") == false and Character:FindFirstChild("CanAttack") == true then
		BlockHandler.OffSetDamage(Player, Enemy)


What are you passing to the Block remote event?

You’re sending the player instance to the block function → but then you mistake it for the players character:

local Humrp = Character.HumanoidRootPart

1 Like

So, I should just make it Character, instead of player for the para?

You should just keep it as the actual player instance just for ease of access.

You should just be able to do the following instead:

function BlockHandler:OffSetDamage(Player, Enemy, combo, damage)

	local Humrp = Player.Character.HumanoidRootPart

So, I changed it back, but the issue was that the Enemy is being equal to nil.

Whats the value of enemy? Could you print it and show the code block of the remote thats firing to server with the enemy argument.


For the client script thats firing the remote, what is the enemy argument you’re sending. Could you send the code related to this.

--\\ GetServices //--
local RS = game:GetService("ReplicatedStorage")
local UIS = game:GetService("UserInputService")
local SSS = game:GetService("ServerScriptService")
local RF = game:GetService("ReplicatedFirst")
--\\ Variables //--
local Held = UIS:IsKeyDown(Enum.KeyCode.F)
local Combat = RS:WaitForChild("Combat")
local Debounce = false
local ButtonDown = false
local Players = game:GetService("Players")

local Player = game:GetService("Players").LocalPlayer
local character = Player.Character or Player.CharacterAdded:Wait()
local HumanoidRootPart = character:WaitForChild("HumanoidRootPart")
-- setting speed
local Humanoid =  character:WaitForChild("Humanoid")

-- \\ Animation-Variables // --

local Block = RF:FindFirstChild("PreLoader")
local Anim = Block.Anims.PassiveAnims.BlockAnim
local Blockin = Humanoid:LoadAnimation(Anim)

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

			while ButtonDown == true  do
			Debounce = false

UIS.InputEnded:Connect(function(input, typing)
	if typing then return end
	if input.KeyCode == Enum.KeyCode.F and ButtonDown == true then
		ButtonDown = false

You’re sending a string to the server but then acting as if its an npc and trying to do Enemy.HumanoidRootPart.

You have no detection system at all?? How were you planning to get the enemy if you aren’t even detecting anything?

It was through Dot that I was trying to get the detection, in the Combat script I used GetPartsInBound, so would I instead use magnitude?