Bullet delay before travelling

Hello! My name is Light and I am a new developer trying to learn how to script.
my goal in the script below was to spawn a bullet everytime this function was ran, the bullet is created perfectly fine but the issue seems to be something with the velocity but im not really sure. When the bullet is created there is a short delay before the bullet actually starts travelling which makes the bullet look laggy or broken. I spent a little bit of time on the forum searching for the issue but didn’t find much that directly related to this, could someone help?

here is a video for reference: https://streamable.com/rpvbz6
and here is the link to the place if you want to see it for your self: Portfolio - Roblox

Below is the script I am using to make the bullet, it’s located in ServerScriptService

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local DebrisService = game:GetService("Debris")
local fireEvent = ReplicatedStorage:WaitForChild("FireEvent")

fireEvent.OnServerEvent:Connect(function(player, gunPos, mosPos)
	
	local bullet = Instance.new("Part", workspace)
	bullet.Name = "Bullet"
	bullet.FormFactor = Enum.FormFactor.Custom
	bullet.Shape = Enum.PartType.Cylinder
	bullet.Size = Vector3.new(0.5, 0.25, 0.5)
	bullet.BrickColor = BrickColor.new("Gold")
	bullet.Material = "Neon"
	bullet.CFrame = CFrame.new(gunPos, mosPos)
	bullet.Velocity = bullet.CFrame.lookVector * 750
	DebrisService:AddItem(bullet, 5)
end)

Any help is appreciated!

There doesn’t look be anything particularly wrong with what you have done. However you are creating every bullet on the server and replicating it and it’s movement to the clients which might explain the lag as it replicates and there might be some Network Ownership issues which relate to the physics handling of objects.
I haven’t written a gun module myself, I just use the standard Roblox Weapons Kit.
Reading other posts a lot of people talk about the FastCast?? method of projectile modelling which might be the way to go.
If you have to reinvent the wheel and make you own model, cast a ray for the gun to project where the bullet will go and send that to the server. Then fire an event to the clients to tell them to model the bullet and it’s trajectory within a local script.

2 Likes

Thank you so much, The network ownership was the problem. I was able to fix it by simply adding “bullet:SetNetworkOwner(player)”

4 Likes