Hi Everybody! This is my first ever Post so sorry if this is weirdly organized.
Just as background info, I’m not a good scripter at all. I just like to script as a hobby for fun when I’m bored and have no homework or stuff
Recently I started making a recreation of Diep.io because as a kid i always played it and since I’m bored, I thought I would try making it on studio for fun.
Before i say anything else I did find a post of another person recreating diep.io : I recreated Diep.io on Roblox and i just want to say that im not trying to copy them and I didn’t even knew this post existed til now, im just making my recreation for fun.
Now the current problem i have is that when moving loads of projectiles, it starts to lag and slows down the game. The current movement system for my projectiles is this :
local BulletSpeed = 1--script.Parent.BulletSpeed.Value
local SpawnedExtraMovement = BulletSpeed + 0.2 -- when a projectile first spawns it has a bonus movement speed which will slow down as the bullet travels
local SpawnedYValue = script.Parent.Position.Y
while true do
script.Parent.BodyPosition.Position = Vector3.new(script.Parent.Position.X,SpawnedYValue,script.Parent.Position.Z) + (script.Parent.CFrame.LookVector*10)*SpawnedExtraMovement
if SpawnedExtraMovement > BulletSpeed-0.4 then
SpawnedExtraMovement = SpawnedExtraMovement-0.02
end
wait(0.03)
end
Heres some examples of how the game/projectiles work
When its only a small amount of projectiles, there really isint any lag.
Now heres a example of 1 person shooting alot of projectiles ( but still not too much of lag )
(Yes I know the projectiles are jittery but when it comes to lag its not much of a issue)
Now this is where the game starts the lag, im going to have fake players called “AutoShootTest” that simulate what having multiple players shooting at the same time looks like
As you can see the game starts to slow down and lag
The lag can also be seen from the Dominator AI (The Giant Yellow Circle AI thingy) where the cannon of the AI starts to spin very slowly due to lag
Now i have tryed 2 other methods for moving my projectiles :
-
TweenService – i actually prefer using tween to move objects however for this situation it gives the same laggy result when there loads of projectiles at the same time.
-
FastCast – Ive tryed looking into FastCast however like I said I’m not a good scripter so this is complicated for me and plus after reading a bit, it just not meant for this type of game as im not trying to make cosmetic bullets
So if there’s any other ways of moving loads of projectiles for this type of game, please let me know! Otherwise I’m basically going to quit working on this project cause i don’t want a laggy game.
Thanks for reading.