I doubt I’ll get any answers on this postbut here we go regardless.

I’m currently attempting to make a small Forsaken clone that includes my friends and original characters as playable characters. Mostly for funbut also to learn more about how to make these types of games.
Basically I’ve now gotten to the part of the game where I need to code a hitbox system. And after finally getting it to work I realized the hitboxes are lagging behind the player.
MedalTVScreenRecording20250616225207-ezgif.com-optimize
(For contextI’m creating the hitboxes on the serverwhich is what is causing them to lag because of ping (even if I have 50 ms but I guess it’d be even worse with higher ping))

I assumed the hitboxes in Forsaken were created on the client and then sent to the server for this to be possiblebut after looking at and decoding some of the source code that a friend gave to meI realized they’re actually being created solely on the server.

I have absolutely no idea how the hitboxes are able to be created on the server without lagging behind the player. I could keep studying the source code to maybe figure it outbut the whole thing is a giant entangled pile of module scripts with unnamed variables and is close to impossible to look through. I could also try to create the hitboxes on the clientbut doing network communication like that is really complicated and not something I’d like to do if there is an easier way.

So my question really is less of “how does Forsaken do its hitbox system” and more of “what possible ways could there be to replicated the way Forsaken does its hitbox system”.

If anyone has any ideas or knowledge they would like to share it would be greatly appreciated!

3 Likes

Maybe make the hitboxes move a little bit ahead of the player. But in a small increment so people can’t hit others out of reach. There is no good way to fix the ping though.

Bytebox explains this really well:

2 Likes

looks like it uses boundingboxes in an area for some time.

workspace:boundbox or something like that

me when i dont read the post fully before replying

6 Likes

Thank you! I finished watching the video.

It seems like Forsaken probably does move the hitbox a bit ahead based on your current movement direction and speedseeing how the hitbox lags when turning but not when walkingand some abilities that make you move really quickly being able to hit people through walls.

I’ll try to implement this tomorrow as it is quite late right nowbut in the meantime if anyone else has any suggestions or ideas feel free to comment themotherwise I will mark this as the solution if it works.

3 Likes

i have heard that you could try invoking the client so it returns the humanoidrootparts CFrame from the players perspective.

1 Like

I updated the code to add AssemblyLinearVelocity * 0.25 to the hitboxes position and it seems to work correctly at 50 ms and have the same-ish delay as Forsaken on 200 msalthough in some cases it still acts weirdly in ways Forsaken doesn’t.
Also after looking at the source code again I realized that they don’t offset the position based on velocitythey just flat out set it to HumanoidRootPart.CFrame * CFrameOffset.
So this doesn’t really seem to be the perfect solutionalthough it’s still a solution and will probably work well enough for what I’m gonna be making.

I’ll probably keep this post up for a bit longer to see if anyone else have any other ideasotherwise I will probably close it tomorrow.
Thank you everyone who have helped! I appreciate it a lot :slight_smile:

i believe it just accounts for your velocity and ping. (and possibly acceleration)
also i’ve heard that the forsaken hitboxes are client sided so the killer’s client decides whether it should hit or not. (i’m not sure is it true tho)

I feel like I should add that a couple days ago I looked through Forsaken’s source code again and found the place where they offset the hitbox.
The reason I wasn’t able to find it before is because the place where the hitbox’s position gets set and the place where the hitbox’s position gets offset are located in two completely separate parts of the script.

But basicallyyesForsaken does do hitboxes in the same way I ended up doingthough with more refined values and different CFrame methods.

Here is the original code with unnecessary referencesoptimizations and obfuscations removed.

local pingOffset = 6.5 - 10 * math.clamp(player:GetNetworkPing()00.3)

local velocityOffset = hitboxPart.CFrame:VectorToObjectSpace(primaryPart.AssemblyLinearVelocity)

hitboxPart.CFrame *= CFrame.new(velocityOffset / pingOffset)

(Note: Since this was made for Forsaken’s hitbox system you will most likely need to modify it to make it work with whatever system you’re usingas I had to do too)

8 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.