Server Hitbox or Client Hitbox for this kind of combat?

I’ve been struggling to code a hitbox system into my game. I tried raycasting, and GetPartsInpart, and I’ve even used Region3 in the past. I did this all on my own but I haven’t been able to make a solid hitbox. I’m just unaware of the type of stuff I need to do in order to achieve a solid hitbox.

Server Side Hitboxes are fair and balanced and with mechanics like parrying and dodging it works. My main issue with server side hitboxes is just mobility. While the players moving around I find it really difficult to hit them.

Client Side Hitboxes though they handle the mobility issues flawlessly. But then it’s the other way around with mechanics like parrying and dodging. The timing isn’t predictable enough and if a player is laggy the hit can be delayed.

So what should I do? I’m confused and I don’t want to move forward on my game if I can’t even accomplish making a good hitbox for the combat. I really don’t get it.

Server Side:

local beenHit = {}
						local whoshitbox = player
						local hb = game.ReplicatedStorage.Storage.Remotes.HB

						hbfire = hb.OnServerEvent:Connect(function(p, hitplayers, combo, timeframe)
							print'1'
							if character.Configuration.Stunned.Value then
								return
							end
							if character.Configuration.GuardStun.Value then
								return
							end
							if combo ~= currentCombo then
								print'nope'
							else
								if tick() < timeframe + 5 then
									print'nope2'
								end
							end
							if combo == currentCombo and tick() < timeframe + 1.5 then
								print'2'
								if p == player then
									print'3'
									for i,v in pairs(hitplayers) do
										local tchar = v
										local troot = tchar.HumanoidRootPart
										local front = root.CFrame.LookVector:Dot(root.CFrame.Position - troot.CFrame.Position)
										if front > 0 then
											-- not facing target
										else
											if not beenHit[tchar] then
												beenHit[tchar] = true
												coroutine.wrap(hitModule.Hit)(character, tchar, combatType)
											end
										end
									end
								end
							end
						end)

						for i = 1,10 do
							if character.Configuration.Stunned.Value then
								break
							end
							local timeframe = tick()
							local hitboxposition = root.CFrame
							hb:FireClient(player, "Box", character, hitboxSize, root.CFrame * CFrame.new(0,0,-hitboxSize.Z*.6), timeframe, currentCombo)
							task.wait()
						end

Client Side:

HB.OnClientEvent:Connect(function(...)
	local C = P.Character or P.CharacterAdded:Wait()
	local data = {...}
	local hitboxType = data[1]
	if hitboxType == "Box" then
		local playerfired, hitboxSize, hitboxCF, timeframekey, combo = data[2], data[3], data[4], data[5], data[6]
		
		local hitboxpart = Instance.new("Part")
		hitboxpart.Size = hitboxSize
		hitboxpart.CFrame = hitboxCF
		hitboxpart.Anchored = true
		hitboxpart.CanCollide = false
		hitboxpart.Transparency = 1
		hitboxpart.BrickColor = BrickColor.new("Royal purple")

		hitboxpart.Parent = game.Workspace.Visuals

		local params = OverlapParams.new()
		params.FilterDescendantsInstances = {C, game.Workspace.Visuals, game.Workspace.Game}
		
		local hitplayers = {}
		local playersInParts = workspace:GetPartsInPart(hitboxpart, params)
		for i,v in pairs(playersInParts) do
			if v.Parent:FindFirstChild("Humanoid") and hitplayers[v.Parent] == nil and v.Parent ~= C then
				hitplayers[v.Parent] = v.Parent
				print'yup'
			end
		end
		
		game.Debris:AddItem(hitboxpart, .1)
		
		HB:FireServer(hitplayers, combo, timeframekey)
	elseif hitboxType == "Touched" then
		local firedHitbox, hitboxPart = data[2], data[3]
		
	end
end)
5 Likes

Server hitboxes would work best here. A laggy player can effectively ruin the entire game with client-side since ping can affect it’s own hitboxes. With slight optimization to the sizes and positions for Server hitboxes it should work 5x better than regular client-side hitboxes.

4 Likes

I agree but the mobility is an issue for me. I know I can optimize it I just don’t know how to optimize it for mobility.

4 Likes

I don’t make custom hitboxes but I would make the hitbox slightly larger than the player to account for their animations.

3 Likes

I’ve tried this I did about 10 size on the width and 8-9 on the z axis. But I may have done my calculations wrong for where the cframing should go. Basically I just cframed it at the root without moving it forwards.

4 Likes