How to make INSANELY smooth grenades

I’ve been trying to make a grenade-like tool but for some reason, the ones in phantom forces are super accurate and insanely smooth to throw, but whenever i try to make one there will be a slight delay and the throw isn’t super great either.

–Example Video
Video (2).wmv (2.2 MB)

3 Likes

Simulate grenades on the client

4 Likes

Yep, generally if you want something to be smooth and responsive you should simulate it on the client like @Ziffixture said.

1 Like

The game might be taking extra time to process the script.

So maybe you can simplify the script?

2 Likes

Handle it on the client and set the network owner to the client that sends it.

2 Likes

It’s simple.

  • Spawn the grenade on the server by using a remote event.
  • Using the server, set the network owner of the grenade to the player who threw it.
  • Apply an impulse to the grenade so it moves.
  • Handle explosion mechanic.
3 Likes

This would invite an initial delay in the throwing of the grenade

1 Like

Yes but I am sure that there is no such thing as a client only grenade.

OP could also use another method.

  • Make a grenade on the client.
  • Make a grenade on the server as well.
  • Destroy the server made grenade on the client.
  • Do stuff.
2 Likes

Of course not. I agree with this outline. The grenade can be made transparent and have its network owner set to nil to avoid any sort of interference or appearance on the client. The client would then report its simulated explosion point to the server, and the server would reconcile with its expectations under a given margin of error

1 Like

Or have it completely destroyed but not by using Instance:Destroy() but rather using:

DebrisService:AddItem(Instance,0)

Setting it to 0 destroys it instantly without any error.

1 Like

You might as well just do:

if grenade.Parent then
    grenade:Destroy()
end

I’m not sure the instance’s destruction is instant with a 0-second delay, as it’s highly likely that Debris:AddItem uses the same internal mechanism as task.delay or task.wait, which in the face of 0 seconds would still wait a frame. That’s negligible though

1 Like

Try it yourself. I am speaking with a lot of experience here. I made a system like this before and if you try to destroy an instance using :Destroy() it gives a warning. To prevent that you use Debris.

1 Like

display the grenade on the client, DO NOT SET THE MAIN GRENADE NETWORK OWNER, it may cause exploiters to teleport the grenade, just in the server script calculate the thows and landing position and send a event to the clientscript and tween the movement, server would handle actual grenade position with a invis part and client will only show grenade mesh with another part. prevents hackers and its more better

1 Like

Debris:AddItem is near functionally equivalent to

task.delay(seconds, function()
    if instance.Parent then
        instance:Destroy()
    end
end)

With the only deviation being that the thread runs outside the context of the script

1 Like

This would not allow for the grenade to interact with its environment. We continue to use physically simulated grenades so they may roll, fall, and bounce off of surfaces naturally. The second approach that @awry_y outlined, and the one I agree with, would not require any network ownership changes on the client due to the fact that all grenades will be created on the client

1 Like

I do know that. And that’s why I am recommending it.

1 Like

That message was addressed to @computerph1_DEV

2 Likes

I mean you replied to me but alright.

You should avoid performing any visual tasks on the server, these should always be handled on the client side. Additionally, there is no need to change the NetworkOwner like other people said. Here’s how you should proceed (bellow):


  1. When the input is pressed or the tool is activated, begin with some sanity checks (cooldowns, raycasting, etc.). Then, fire a remote event and immediately play all effects on the LOCAL client (for yourself only). This includes throwing the grenade, emitting particles, and playing sounds.
Tool.Activated:Connect(function()
    --Sanity Checks (Cooldown, Raycast...)
    --RemoteEvent:FireServer(GrenadeHitPosition and other arguments you need)
    --Play grenade effects (for yourself only)
end)
  1. When the server receive the event, redo some sanity checks to make sure there is no exploits. Then, do damages to characters and FireAllClient.
RemoteEvent.OnServerEvent:Connect(function(Player, GrenadeHitPosition)
    --Sanity Checks (Cooldown, Raycast...)
    --RemoteEvent:FireAllClient(Player, GrenadeHitPosition)
    --Do Damages - Setup Cooldowns

    --Character may be found with Magnitude, GetPartInPart or whatever else using GrenadeHitPosition
    --You can also get characters in client side, send them to the remote and do a magnitude check here in server side, just to verify any potential exploits, but don't forget to consider delay and ping (0.1s - 1s max) so if characters are a bit out of range, you could still do damages
end)
  1. When all clients receive the event, the LOCAL client (yourself) won’t play the grenade effects, but all other players will be playing your grenade effect from their point of view.
RemoteEvent.OnClientEvent:Connect(function(OriginalPlayer, GrenadeHitPosition)
    if not (OriginalPlayer == LocalPlayer) then
        --Play grenade effects from the OriginalPlayer to its GrenadeHitPosition (not for yourself)
    end
end)

This approach ensures that your grenade is thrown immediately, with a smooth movement and effects from your point of view as well as from the point of view of other players.

There is still a natural delay of 0.1 to 1 second between the moment you throw it and when other players see you do so, depending on their internet connection or wifi, but players are unlikely to notice this delay. Additionally, there should be no problems if you prevent and handle this on the server side.

4 Likes

there are alot of great solutions in this post. However, i will have my opinion, what u can do is throw the grenade on client and also on server at the same time where client will be handling the grenade visually, have the trajectory precalculated on server, so when the grenade is landed on server meaning trajectory is completed (t = 1), get the client position of grenade using a remote event. Now do a radius check for security, if radius of client grenade is in range of server trajectory calculation, explode the grenade. Now this may require some changes to physics behavior of grenade part on client, since sometimes it can bounce off to farther distances