Game doesn't work when it first starts up

I’ve been working on a project and whenever I first load into a server animations bug out and hits dont register for whatever reason.
After a bit they end up working. I was thinking of just making it so if its a new server it waits X amount of time before u can play so everything works but u have to actually use the weapon first for a bit before it works. Once one player uses the weapon it works for everybody else.
https://gyazo.com/40cf7aa422d61c0c85957abc043326ec
How can I fix this? I use gettouchingparts for my weapons.

Are you using gettouchingparts on the server or the client?

The server of course so exploiters cant mess with anything.

You might have something in your script that makes it load that way, but your guess is as good as mine without any provided code.

The thing typically thought to be best practice for most hit detection is to do it on the client while doing sanity checks to make sure its “realistic” to the client
If done on the server you can run into a ton of issues where obvious hits miss, especially with stuff thats moving
Pretty much every major game, even professional AAA games, use client sided hit detection which is why anti exploit is so prevalent in many fighting games
If it was done on the server there would be so much desync it would be unplayable

If executed correctly, the only thing an exploiter can do is aimbot (which can be done with server sided hit detection anyways, its just slightly and it might miss every once in a while), so I recommend that you consider changing it to client sided hit detection

Pretty much the only checks you have to do is, on the server:

  1. Is the person somewhat near the target
  2. Is the person facing the target
  3. Is there a massive wall between the person and the target

This could very easily solve the problem due to the loading of animations on the server or some other random inaccuracy caused by server sided hitreg
Im not guaranteeing this is the problem but its most certainly good practice

2 Likes

a small concert with that is
here is how my hit system works
Fire remote event:
Play swing sound + animation
wait X amount of time
Gettouchingparts and determine who gets hit.

I would have to play the animation on the client which isn’t a problem but a new problem arises
playing the swing sound. I have to wait a short amount of time before I fire the remote event if im registering the hit on the client.
I cant play the sound on the client since it should be heard by other players.
If I make a remote event to play the sound exploiters can just spam the sound. Even if I try making some type of cooldown it can still be abused.

I would ensure each sound is linked with a valid hit and is rate limited
This would make it so only when they could be hitting and validly playing a sound can they play the sound

So:

  1. client detects hit
  2. client tells server
  3. server validates hit w/ rate limit, distance checks, front checks etc
  4. server plays sound after validated

the thing is the swings have a windup meaning the client should only detect a hit AFTER the sound is played. So the sound has to play before the remote event fires. If I make a seperate sound remote how can I protect it fully?

I have an idea but idk if its the most viable option.
the sound plays from a diff remote event.
after the sound plays it waits for the swing remote event to be fired by the player
if the swing remote event does not play the player gets punished
there would also be a cooldown in place so that you cant spam it 5 times prior to a swing to bypass the sanity check

Oh I see what you mean now, I thought you meant a hit sound rather than a swing sound
I might do that but I personally would just use the remote event itself to play the sound and just rate limit it
As long as the sound isnt played across the whole server I cant imagine it could be too easily abused with a cooldown
A normal player could spam the sound just as easily as an exploiter in this case, so I wouldnt consider it a security problem as much as it is a cosmetic problem

1 Like

I just finished reworking a couple weapons and it 100% works better. I was able to add lots of anti-cheat as well and exploiters really cant do much.

tysm for all the help :slight_smile:

1 Like