Moving an object on the server or fireallclients?

Been wondering about this recently, I have a section in a game mode where after an allotted time, doors (models) open to special areas. My question is–would it be better to fire all clients or continue doing it on the server as I heard it raises memory consumption, I’m not sure if it would apply here. (Also worth noting–when making the bellow code, I did not know how to use tween service, I may decide to reconfigure it to tweening but it does its job right now.)

-- Done Inside server script.
StringVal.Value="The doors to all of the rooms are opening!"
		for i=0, .5, .01 do
			model1:SetPrimaryPartCFrame(model1:GetPrimaryPartCFrame() *,i,0))
			model2:SetPrimaryPartCFrame(model2:GetPrimaryPartCFrame() *,i,0))



note, there is also code to reverse the change–i.e. close the doors after a certain amount of time

Hmm … It depends what you want, if you use FireAllClients, it will only move for current players, but the change will not be seen for new players.


There are a couple of issues with this. First and foremost, .01 is not a multiple of a power of two. You will get rounding errors. The extra fun, cumulative rounding errors by the look of it. Second, you are moving the door by i, which changes each iteration. Here’s a little fix that should work better and won’t suffer from cumulative rounding errors.

local openCF = some CFrame
local closedCF = another CFrame

for i = 1, 50 do -- open the door
    model1:SetPrimaryPartCFrame(closedCF:Lerp(openCF, i/50))

As for your main question, it’s not going to matter for something this small. But to do it properly, you would do it with a RemoteEvent. You would just tell the LocalScript to open it, rather than telling it the position. This matters more with something like a large shooting game. Hundreds of bullets. If you make the bullets on the server, then Roblox will inefficiently try to keep the projectiles in sync. But they move so fast and you can draw a hit marker anyways, you merely need to tell the LocalScripts to draw a bullet with this position and this direction, and save a lot of network resources by not synchronizing them.

1 Like