Gun bullet offsets a little bit in front

So I have this issue where when I fire a gun, the bullet spawns like 5 studs in front as you can see here:

Video Version:

I don’t really have an idea what could cause this. But maybe some of you know how to prevent/fix it.
Thanks!

Could you show us every scritp related to the bullet?

Visualizer:

That is probably because you are handling the bullets on the server, instead you should send a RemoteEvent to all clients to render the bullet and the person shooting should not render it via the remote event because you want to render it immediately on their screen when they click.

Basically check:

local LocalPlayer = ...
-- connect this to the render event
local function onRenderEvent(playerWhoShot, ...)
   if playerWhoShot == LocalPlayer then return end -- dont render it

   renderBullet(...) -- use a function to render the actual bullet
end

tool.Activated:Connect(function() -- on fire
   -- send remote event to the server
   renderBullet(...) -- render it because you shot it yourself
end)
1 Like

Could you explain what is muzzlepos and endopos?

I’ll give it a try
\\\\\\\\\\\\\\\\

Muzzlepos: The possition of the FirePart (where the bullet should start)
Endpos: Mouse Position to wherever the bullet is going

I think I m to what’s the problem, maybe it’s at line 21 because you are adding an offset to the bullet?

This is a server-script correct?

If it is that is the problem, you should instead render the bullet on every client.
Client -> Render (Client) & Server
Server -> AllClients RenderEvent
OnRenderEvent (Client) -> If you didnt shoot it -> Render

This seemed to fix it. Thanks!

1 Like

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