Lag with BasePart.Touched

INTRO

It’s not a good idea to use .Touched for damaging stuff, it relys on physics and most of the time it’ll be inaccurate. If this big enemy we’re talking about swings a sword, it might be best to install a Raycast Hitbox Module, which is here: Raycast Hitbox 4.01: For all your melee needs!

OTHER SOLUTIONS

You could use Raytracing to detect players getting hit by Big Enemy. The link I provided has a code example, so you should be good.

GENERAL CODE REVIEW

if game.Players:GetPlayerFromCharacter(hit.Parent) then

local player = game.Players:GetPlayerFromCharacter(hit.Parent)
							
local CanBeDamaged = hit.Parent.RemoteHit:InvokeClient(player)
							

This part has quite a bit of flaws. Firstly, the if game.Players:GetPlayerFromCharacter(hit.Parent) should be saved into a variable, to prevent further yielding and visible “hops.” Also, when you call :InvokeClient on a RemoteFunction The scripts yields waiting for that response, so essentially, a exploiter could override the Invoke callback on the client and break your entire script.

The part where when we can apply damage to the player also has a flaw, you should really save the Damage module in a local reference, rather than requiring it every time, which would be extremely expensive (I think.) when using physics-based events.

IN ALL,

Don’t use .Touched for hit detection, it’ll save you tons of headaches and testing.