Note: I am using filtering enabled so the script runs on the server.
I've noticed when creating bullet projectile scripts that as I increase the number of players shooting that the lag created from these projectiles abnormally increases (almost exponentially?). I know that another possibility besides my bodyForce script is to use interpolation and repeated raycasting but is this the best way to go about doing it? This is my current script:
function _M.CreateBullet(weapon, pos)
local basePos = weapon.Barrel.CFrame.p--:toWorldSpace(CFrame.new(0,weapon.Barrel.Size.Z*0,0)).p;
local direction = (basePos - pos.p).unit;
local bullet = Instance.new("Part");
bullet.Name = "Bullet"
bullet.Transparency = 0;
bullet.Size = Vector3.new(0.2, 0.2, 2.6);
bullet.CanCollide = true
bullet.CFrame = CFrame.new(basePos, basePos + direction); --make only one end come out of barrel
bullet.Velocity = -1*(direction * 5);--bullet.CFrame:toWorldSpace(CFrame.new(0,0,1)).p;
--bullet.Position = basePos;
--bullet.Anchored = true;
local BF = Instance.new("BodyForce")
BF.force = Vector3.new(0, bullet:GetMass() * (game.Workspace.Gravity - 0), 0)
BF.Parent = bullet
bullet.Parent = game.Workspace.Bullets;
spawn(function()
bullet.Touched:connect(function() print("touched") bullet:Destroy() end);
while (bullet.Position - basePos).magnitude < 500 do
game:GetService('RunService').Heartbeat:wait();
end
bullet:Destroy()
end);
end
I happened to see this on twitter and was very curious on how he did it. Anyone know how he successfully created that many moving projectiles at once? https://twitter.com/Silenxed/status/881224824047243264
