What's the best method for Client-Hitboxes?

I made client hitboxes but honestly it looks very unscalable for other move types. What checks would I need for projectiles/ranged attacks and aimed attacks where it moves based on where you’re facing?

And how can I improve the Server checks in general? I was planning on doing raycast and vectordot, but I would have to add very specific checks. Like what if I want a move to hit from the side of the player? Any ideas? I literally can’t find Client-hitbox code to build from.

Server sends Hitbox Data
MarkerSignal = LoadAnimation:GetMarkerReachedSignal("Combat"):Connect(function(Frame)
			if Frame == "HitFrame" then
				StateManager:GetMetaData(Character).MoveData["M1"] = {StartTime = os.clock(), HitboxData = HitboxData} -- This table just holds a spot to store MoveData
				ReportHitbox:FireClient(Player, "M1", HitboxData)
			end
		end)
Client creates Hitbox and sends hit results to server
-- Im not sure if sending the potential hitposition from the client -> server is the best idea
RemoteEvents.ReportHitbox.OnClientEvent:Connect(function(MoveType, HitboxData)
	local function SendInfo(Victim)
		RemoteEvents.ReportHitbox:FireServer(MoveType, Victim, Victim.HumanoidRootPart.CFrame)
	end
	
	Hitbox:GetPartBoundsInBox(Character, HitboxData, true, SendInfo)
end)
Server does safety checks
RemoteEvents.ReportHitbox.OnServerEvent:Connect(function(Player, MoveType : string, Victim : Instance, HitPosition : CFrame)
	if (typeof(Player) and typeof(Victim)) ~= "Instance" and typeof(HitPosition) ~= "CFrame" then return end
	local Character = Player.Character
	
	if Victim == Character then return end
	local MoveData = StateManager:GetMetaData(Character).MoveData
	local ServerHitboxCF = Character.HumanoidRootPart.CFrame * MoveData[MoveType].HitboxData.CF
	
	if os.clock() - MoveData[MoveType].StartTime <= MoveData[MoveType].HitboxData.Duration then
		if (HitPosition.Position - ServerHitboxCF.Position).Magnitude <= 6 then
			MoveData[MoveType] = nil
			print("yes")
		end
	end
end)
1 Like

still looking for a alternative

Use raycast and just show the effect on the client.