#How to not lag if there are 1000 parts in your game?
1 messages · Page 1 of 1 (latest)
Setting the network owner to nil switches to the server, and that will lag the server
but you can turn off CanCollide or use CollisionGroup so there is less physics lag
What would you recommand me to do? I set the collision fidelity to box a least lol
Do you think 1000 part is excessive?
no, this is not true
1000 parts is nothing. 1000 moving parts is something else entirely. most of the lag is going to come from the network. simply sending physics data for that many parts takes up a lot of bandwidth.
so no, setting network ownership isn't going to really change anything.
agree
if you were want to do 1000 parts
visualize it on client
ya have to do some shenanigans to make the moving parts client only
Thought about that but it's cooler if everyone sees it
What if they only move on the x asis. I mean on a conveyor
perfect
no. they're still subject to physics
that makes it easier to visualize on the client
then send it on all client
simply enough
8 clients, 1000 parts per client
done it server, it'd choke your network
I mean max 1000 on all the servee
still the same tho
clients should simulate the moving parts for themselves
bunch of different ways you can do this, like firing a remote to all clients to make them spawn a part.
So only the client would see theie part
yes, every client would see a different part, but they would see it in approximately the same location
yes
Hmmm
then to have the server simulate the actual part's movement, you could make one on the server and parent it to the server's camera.
Yeah lol I was looking for the worst case
stuff parented to servers camera doesn't replicate, but is still subject to physics
so you can still physically simulate the part moving along the conveyor without it replicating
server'd see it , right?
That's intresting
ya so the server knows when the part touches the seller
What about 200 moving parts?
thats possible? wow.
otherwise you'd have to calculate how long it should take for the part to reach the seller at the end
yes i do this
all the time
using maths
ya that's the hard way. it's probably the better way, but also much more difficult.
theres server camera?
Preorganised path could work too right?
yes
i'd look more into this
ya if you move the part along fixed rails, like a path you know beforehand, then you should be able to calculate the duration very easily
so parts on client, parent it to server camera?
having the server physically simulate the part is lazy method and works about as well
but doesnt that will increase physics on server?
who cares
it's the server
roblox servers are surprisingly beefy
the only real bottleneck is networking
you're right
if you wanted it done "right", you'd do this method, because you can guarantee things. if you instead rely on physics, well occasionally parts can fall off the conveyor.
but maybe you want that
So overall would you recommend me to create preorganised path or the server simulating the part moving?
one of the two, ya
neither is inherently better. the premade path is more physically reliable but harder to make (parts wont fall off, duration of journey to end of conveyors is definite and known in advance, easier to sync all clients with where the part actually is), vs physically simulating a copy on all clients and the server (parts can fall off, duration of journey is unknown, parts can desync between client and server appearing in different locations, but is significantly easier to make for a beginner)
ya there's always more than one way to do anything in code, and the decisions always ends up a balance of difficulty vs what you're trying to do vs what you're comfortable letting slide
Yess
** You are now Level 10! **
english premium at its finest
i.e the desync between client and server in this situation is largely negligible
Yes
I'm not sure I get the second option
How is it called, so I can watch tutorials and get better 😅
if you need a tutorial then i suggest you watch beginner dropper/tycoon tutorials and disregard everything in this thread
and accept that you won't be dealing with the 1000 parts situation at all.
if it lags your game, it lags your game 🤷
Yep I can also reduce the ammount of parts for now it's maximum 100 parts per server
at least until you know enough about scripting that you can understand what you need to do to accomplish a technique just by hearing its description like here.
Yes
most established scripters can do this no problem
all scripters ranked s1+ can do this also
so you got work ahead of you if you want to be a scripter
for now tho best advice is just keep making bad stuff until you get good enough to make good stuff. considering problems like 'wat if i had 1000 parts' is a good sign, but solving problems like this takes skill, and that can take a while to develop - there are no ai shortcuts unfortunately 👍
Yesss! 🫡 I will try my best to get better. Thanks a lot for the tips 😁
So it's better and less laggy that everyone spawn their part and the other's people part on their device(local) than if the server spawn 1 for everyone?
Because FireAllClient is easy and fast to change lol
wat no the bottleneck is bandwidth so spawning the parts on each client = 0 bandwidth
otherwise the server (or a client with network ownership) needs to send the physics to every client
for 1000 parts this is easily over 300kB/sec
ideally a game should be under 50kB/sec
So local is better?
100kB/sec if you're being generous
press ctrl+f7 for a basic net graph. Sent/Recv combined should be under 100kB/sec at all times if you can help it.
for reference
But if I do it local people's phone calculating all the parts physics will make reduce their fps ?
try spawning 1000 parts just on their own, and the only special thing is they are unanchored.
then look at the graph
bruh
there's always more than 1 way to skin a cat, in fact with programming there's usually infinite ways to do anything
I think I'm not catching something
you're not catching the fact there is almost never an ultimate final "correct" solution.
there is no "it's always better to do X"
Oh yeah
it always depends.
But spawning parts on server or spawning parts on local?
Or Each have their weakness
it depends. each have their pros and cons, strengths and weaknesses.
If everyone had a rtx 5090 then I would do it on local?
graphics is not the bottleneck
Then why wouldn't local be always better?
you lose net sync
that meaning, the part exists in the same condition and location on both client and server at the same time, and is responsive to physics i.e walking your character into a part to push it.
when its client only, there is no net sync. the part is unique to that client.
usually reserved for parts that are purely visual in nature, which an item on your conveyors would be.
Thats exactly my case
e.g when you do a downslam and prop debris goes flying everywhere, most of the time those parts are on the client, there's no reason for them to exist on server since they are purely visual
it does mean it looks different for every client, but if that's not important then it doesnt matter
e.g if you had an ability that spawned a bridge in front of you that other players can walk on, you'd want to either do that on the server, or do some shenanigans where it spawns a copy on all clients
so it has a mix of the purely visual while having some net sync
So I will make a FireAllClient() to spawn parts
Do you know if any device could run 1000 moving parts on local(their phone or tablet)?
this is not good enough on its own for a dropper/seller/conveyor thing like a tycoon
ya most phones should be able to do 1000 moving parts particularly if their collisions are trivial
I don't get what you mean
i.e, the 1000 parts do not collide with each other and are only colliding with the world or anchored parts only. collisions are non-trivial when its between 2 or more moving parts, emphasis on the more.
1000 unanchored parts in a small pile in the center of your baseplate has wildly different physics costs compared to scattering all the 1000 parts across the baseplate so none of them are touching each other.
Yeah I will make collision groups so the parts dont collide with eachother but only eith the conveyor
atp just make them have a predetermined path so you skip the physics processing
either or, they both work 🤷
But @warm pewter for a yes no question, would you put dropper parts on client or server?
im not making a game with droppers so idk
i would pick whichever suited my game the best compared to the effort im willing to put in
if its on client other players wouldnt see your droppers dropping anything, are you sure you want that?
i mean
i guess if it works it works
fireallclients, not just one
On clienr for everyone
yeah but then they would only be able to see their own dropper no?
No
For example My device would load all your parts and mine
You would load them too
i see wym
i think bro just figured out client/server architecture
Client? 😂
nah
😂
i just didnt get what he meant
the step to realize the server is singular, and the clients are many and each have their own version of the world, is one that a lot of beginners struggle to make.
I know the difference
I just don't see the downside of using client to spawn dropepr part
Since you said graphics aren't the bottle neck
ya for a tycoon game in this situation there isn't too much downside
but there is one: the server still needs to know when the part touches the seller at the end.
otherwise it's just a part moving along a conveyor and the player gets no money from it
Touched wouldnt work?
Since its not server hmmm
well its on the client, what is .touched going to do?
client cannot give itself money, that's a bad idea 
that's the client giving itself money...
exploiter: "hey server can i have 99999999 money i swear i just sold the best block in the game joined 5 seconds ago" server: "sure"
Lol
Any way to resolve that 🤔
ya thats why i said with this technique you'd also want one of the parts on the server too, same as the clients, but for the server one you parent it to the server's camera so that it doesn't replicate (nothing gets sent over network)
and then you can use that part as the trigger
ya
And if I parent it to the server cam is it visible?
Or I can just change it's transparency
no, parenting to server cam keeps the part physically alive without replicating it
e.g it is subject to gravity and whatnot, but only the server can see it.
it's a bit like making a part on the client how it doesn't get sent to server. same thing but opposite direction.
you need the parent to camera step to make that work.
ya
Ohhhh
all this to avoid the 300kB/s+ bandwidth cost of 1000 moving parts.
code do be like that
anyway good luck, i think you got this 
One last question 😁
Will the client part and the server (camera parent) part collide?
Nice
So wait is it easy to change? I just FireAllClient() and also spawns part and parent them to the server camera?
that's the main part of this method yes
you can add stuff to it and make it more complicated obviously
like make some effort to sync the parts like they have a shared guid so when the server sells the part it can notify all clients that it was sold so each client in turn can remove their version of that part
Oh yeah right the server part and the client part will not be at the exact same place
How bad is the delay?
they are completely different instance, so you may want them to have a unique number so you can pair them up later
about 250ms on average
Not bad
50ms from roblox physics, 200 from network latency
They will get their money +-250ms when their parts hit the cash collector
Client part are only for the looks why do I need to pair them?
so when the server does something to the part, like sell it, it can notify all clients what happened to that part
e.g if for one of the clients the part fell off the conveyor, it would stay there forever
you can either link it with a httpservice:generateguid orrrr just ignore it and listen for touch world or whatever and accept the desync
you need to try some of this stuff out bruh
asking isn't going to get you anywhere atp
why are you still here go build it 
Right lol
Have school in 7h30 hours, need to go sleep 😂😂
I just delete it
maybe do that first, studio will still be here tomorrow
Nice
Horror game
Oh
with any luck you'll find out when its ready
Is it your first game?
Ohhhh
haha no
😁
have made a fair few games outside of roblox, 2 finished and released games on roblox (not great games tho, just practice, but they are completed)
Oh thats cool
How old are you?
What will be the name so I can try it?
And around when will you make it public?
most likely older than you
idk i havent decided. it'll be done when its done 🤷
I'm 18
Yesss
@warm pewter I haven't found anything online about server camera, do you know where I can find more info?
Does it work on any camera that you put on your explorer?
I will try it once I get home
So I could just delay the client spawn with task.wait(0.25) ? 🤔😮
(Making the FireAllClient() then task.wait() then spawn the server side dropper part)
Task.wait(0.25) would work for the average people ig
But for people with less and higher ping