Players lag when destroying parts on server side

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    For the players not to lag like crazy when the server destroys parts.

  2. What is the issue? Include screenshots / videos if possible!
    The game lags when the parts are removed on the server.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I’ve tried to move all the stuff to figure out what parts to destroy from server to client and visa versa.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

Client Script

local goOut = function(piece,range,damage)
	local ball = game.ReplicatedStorage.requiredParts.hitCircle:Clone()
	ball.Position = piece.Position
	ball.Size = Vector3.new(range,range,range)
	local parts = {}
	for i,v in pairs(workspace:GetPartsInPart(ball)) do
		if v:IsDescendantOf(workspace.walls) and v.Parent ~= workspace.walls and v.Parent.Name == "default" then 
			table.insert(parts,v)
		elseif damage == 2 and v:IsDescendantOf(workspace.walls) and v.Parent ~= workspace.walls and v.Parent.Name == "reinforced" then
			table.insert(parts,v)
		end
	end
	neededStuff.evs.wallsRemove:FireServer(parts)
	services.debris:AddItem(ball,0)
end

Server script

evs.wallsRemove.OnServerEvent:Connect(function(p,parts)
	table.foreach(parts,function(_,p)
		debris:AddItem(p,0)
	end)
end)

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

1 Like

Instead of debris you can CFrame the part away like in partcache.

Also if you play test in roblox the players wont lag but the server will.

This is because studio simulates the server as well so its twice as laggy there.

Also try not using debris

2 Likes

I have tested the game with other players in the actual game on roblox and it still lags everybody, I will try do what you said to do though.

This worked perfectly for me and completely negated the lag, thanks man.

1 Like

No prob also noticed you are using my view model spring.

Hope it helps your game out

Yes thank you, it it really good and it has basically been what I was looking for, for a while. I don’t really know how to use the spring module so it was great to have a basis to work off!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.