How to hide other player bullets?

So in my game, all the bullets are server-sided, but is there a way to hide other player bullets? I was thinking that if an object is loaded in, and its a bullet, to delete it on the client. But is this laggy? I’m unsure if there is a better way to hide their bullets.

In any case, it depends on how it is set up. For you, it is purely server-sided. In this case, if not already, I would recommend storing them in a Folder with a specific name. This ensures that they are easy to locate from any script in the game. Another possibility is to tag them with CollectionService.

Server Script:

local CollectionService = game:GetService("CollectionService")
local Bullet = Instance.new("Part")

-- Whatever other code you use.

CollectionService:AddTag(Bullet,"Projectile") -- Tag doesn't matter. Just keep consistency.

LocalScript:

local CollectionService = game:GetService("CollectionService")

CollectionService:GetInstanceAddedSignal("Projectile"):connect(function(Object)
     Object:Remove()
end)

As I do not have access to your current code, just apply what I have given you to your code. The alternative is using a Folder or Model in workspace, and connecting ChildAdded to a function where it removes the bullet (all done on the client).

Hope this helps.

  • Galactiq

Don’t render bullets on the server. The server has no reason to render bullets.

Use RemoteEvent:FireAllClients() with the parameters being:

  1. The player who fired the shot
  2. The end destination of the shot

Compare the local player and the player argument received by the server.

if PLAYER_WHO_SHOT == LocalPlayer then
    --do the hokey pokey
else
    --client did not fire this shot, do not render
end

Remember to sanity check on the server. The server’s role in this entire process is to validate the shot and process any hits. The client(s) themselves should be the one to render/visualize things.

2 Likes