i’m working on a bullet trail script and i finished it but i found out that it causes a lot of network usage. (pic below)
here is the script: (client)
while true do
wait(0.1)
local trail = Instance.new("Part") -- part with a trail inside it (removing it doesnt change anything)
trail.Parent = workspace.Debris
trail.Position = Vector3.new(0,0,0) -- some position (doesnt matter)
local BodyVelocity = Instance.new("BodyVelocity")
BodyVelocity.P = Vector3.new(10000,10000,10000)
BodyVelocity.Velocity = workspace.CurrentCamera.CFrame.LookVector * 250 -- where to direct the part
BodyVelocity.Parent = trail
end
note: this isnt the exact same script, i replaced some stuff so you can test it out
Never ever ever parent a part before you set all of its properties! This is a major bottleneck for any roblox instancing code and should be avoided at all costs. Put the .Parent line after setting the position and see if it makes a large difference. Furthermore, do you really need to instance a new part that frequently? Maybe for a trail you could use beams or particle emitters.
Hope this helps.
Edit: Seeing that you only set the position to the origin, it’s probably just the fact that you instance a new part and constraint so frequently. This will also cause major lag when you add more players.
That is the best solution for OP. Trails are likely the most network-efficient way of creating bullet trails, and are easily customization. No matter how you handle it, creating a part every frame (or every 0.1 seconds, in your case) is going to have a toll on performance (not to mention also creating a BodyMover and running those physics every frame too, yikes).
They’re not the most difficult to implement (see here) and should suit most people’s needs.