local RE = game.ReplicatedStorage.RemoteEvent RE.OnServerEvent:Connect(function(p,m,Tool) local bullet = game.ReplicatedStorage.Bullet:Clone() bullet.Parent = workspace bullet.Size = Vector3.new(1,1,1) bullet.CFrame = p.Character:FindFirstChild(Tool.Name):FindFirstChild("Handle").CFrame bullet.CFrame = CFrame.new(bullet.Position, m) bullet.CanCollide = false local BV = Instance.new("BodyVelocity", bullet) BV.MaxForce = Vector3.new(math.huge, math.huge, math.huge) BV.Velocity = (m - p.Character.HumanoidRootPart.Position).Unit*600 end) --p = player --m = Mouse.Hit.p --Tool = The tool.
I shoot with the gun, it goes a bit in the direction it should be, then it stops for around 0.1 seconds, then continues. any way to fix this?
It's likely a quirk with the roblox engine, i've struggled with it before. You probably can't fix this but there is another alternative that doesn't have this problem, raycasting.
I would just advise you to look more into raycasting if you're trying to create a gun in roblox.
This is caused by the Network Ownership system. Every physically-simulated object in the game is automatically assigned a Network Owner that handles the object's physics calculations, and then replicates them to the server/other clients. Even if you instantiate the object on the server, the Network Owner may be automatically set to the nearest client. As the bullet travels further away from the player, the Network Owner changes from the client to the server, again, automatically. Every time a physically-simulated object switches Network Owners, there's a "hop" in the object's physics simulation. This "hop" is the amount of time it takes for the Network Owner to be switched, usually dependent on the latency between the old owner and the new owner.
I would suggest, anywhere in your code after creating the bullet, manually setting the bullet's Network Owner to the server. Manually setting a Network Owner will ensure that it's not automatically changed.
You can do this like so:
bullet:SetNetworkOwner(nil)
Passing nil
to BasePart:SetNetworkOwner()
will set the owner to the server. Otherwise, you can pass a Player object to it and it'll set the Network Owner to that player.
This information comes directly from this article, if you want a more in-depth explanation.