Adding and removing bases on the client!

So im trying to reduce lag by adding a section to settings where you can remove other players bases… However I am not sure how to put them back…

Code:

wait(4)

local base = game.Players.LocalPlayer.PlayersBase.Value
local base1 = game.Workspace.Base1
local base2 = game.Workspace.Base2
local base3 = game.Workspace.Base3
local base4 = game.Workspace.Base4

script.RemoveBases.Event:connect(function()
	if base ~= base1 then
		base1:Destroy()
	end
	if base ~= base2 then
		base2:Destroy()
	end
	if base ~= base3 then
		base3:Destroy()
	end
	if base ~= base4 then
		base4:Destroy()
	end
end)

script.Add.Event:connect(function()
	local bases = game.ReplicatedStorage.GetBases:InvokeServer()
	local base1v = bases.Base1
	local base2v = bases.Base2
	local base3v = bases.Base3
	local base4v = bases.Base4
	if base ~= base1v then
		base1v:Clone().Parent = workspace
	end
	if base ~= base2v then
		base2v:Clone().Parent = workspace
	end
	if base ~= base3v then
		base3v:Clone().Parent = workspace
	end
	if base ~= base4v then
		base4v:Clone().Parent = workspace
	end
end)

Please let me know how I could do this, thanks! :smiley:

You can just store the locations of the bases before you remove them and then just move the base back to that stored location when you are adding them back.

well if a players adds something to their base it will not add it for you.

1 Like

Since you are using a remote function to get the bases, why don’t you just return the location of the base?

1 Like

what if the player adds something to their base… it will not update it for you.

1 Like

That’s a whole another issue. I’m trying to help with simply placing the base back. Try firing a remote event to update the other bases that are currently being shown whenever a base is updated. I think there’s a better way of doing it but you can at least try it. :confused:

1 Like

would putting the base in something like replicated storage lower lag?

1 Like

It could lower FPS lag (not entirely sure) as it is not being rendered anymore, but it would still use the same amount of memory i think.

does using memory cause lag?

1 Like

I dont think memory usage directly causes lag, it really just depends on the base size, the amount of parts, unions etc

1 Like

is there a place I could put it where it would not use both?

Deleting it would remove it from memory, like you originally tried

Im not sure how you would go about temporarily removing the base and then reviving it though

ok im putting it in replicated storage. should help a bit.

1 Like