You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
For the players not to lag like crazy when the server destroys parts. -
What is the issue? Include screenshots / videos if possible!
The game lags when the parts are removed on the server.
-
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.