Punches are slower in game than studio

Hello. I’ve been working on a fighting game. However I got stuck in making combat because of one problem. When I click, the client fires a server and there’s a 0.15 seconds delay before the hitbox is created. After that the server creates a hitbox and fires the client, client waits for 0.25 seconds before another punch. So the problem is that on studio it works well but in game it’s slower. There’s a similar topic to mine, but it didn’t help me: Script faster in studio than game?
I know that it should be slower in game, because when you test your game in studio, your computer handles client and server at the same time, so it’s faster. But I’ve seen good combat systems in other fighting games and they weren’t slow like mine. I don’t think developers of those games made the delay between punches like 0.08 seconds so it’s pretty fast not only in studio, but in game too. Thanks for reading. Any help is highly appreciated.

You might have certain scripts that could be causing latency/issues which would only ever be executed in a game environment as opposed to the studio environment. Check for any foreign scripts in your game.

There is always a latency between client and server, normally around 200 ms latency. In order to work with this, games that have responsive input to output(replication) utilize creative approaches to ensure both the client experience to quality as well as security on the server.

Studio does not house this latency, since it is “locally” creating this server for you and the latency is virtually non-existent(but not non-zero). You can artificially add latency if you desire to on Studio Settings to simulate the latency.

1 Like

Thank you for the responce. I’ve checked everything in my game. There are almost no objects, scripts are only mine. Moreover I placed the combat script in other empty place, the issue is the same.

That’s new for me. Do you mean this by Incoming Replication Lag feature?

I’ve heard even about client-sided hitboxes, maybe that could be a solution? Anyways, I’d like to minimize the delay between punches. Can you recommend some tips, please? I can show the code if needed.

I’m not sufficiently experienced in this field of work, but I’m pretty sure that in theory, you will have a few remotes to fire to process the hits from client for security, stopping the outliers of all the hits.

Hey, I am the writer of the post and I found a pretty upsetting yet straightforward answer:

  • Hitboxes using Region3 & .Touched are much much slower than other kinds of hit detection.
    (although they appear fine on studio)

  • Effects should ALWAYS be played on client and then replicated to other clients, the effects are the main reason the hit looks delayed.

No matter what you try, as long as you fire a remote event, there will always be a slight delay, what you can do is just make it better by hiding the delay.

For example:
I hide the health bar of players from being shown to other players and play effects on client.

Effects played on server:

Effects played on the client:

it makes a huge difference

1 Like

Hello. Glad to see you. I make all effects on client, and I agree, that they make a huge lag. I haven’t tried the region3 hitbox type yet, but I often use the :GetTouchingParts() function with a .Touched connection before it so it can work. I use just .Touched connection only in ranged attack cases. Thanks to @Operatik, I’ve learned how to make my local studio server have some delay like in a game, so it’s easy to set the optimal speed for punches for my game. But the solution may be making all the functions on the client side of a player with sending some remotes to the server to make some sanity checks, do damage etc. If you have any ideas how to make it or even another solution, I’ll be happy to listen to you!