-
What do you want to achieve?
I want to get all nearby parts to another part in a quick manner. This is done to delete parts that are too close to another player’s parts. -
What is the issue?
There’s a noticeable delay when placing parts on my build tool when there are a large amount of parts present within the server. -
What solutions have you tried so far?
I’ve been going through every part in the game that shares a parent with other player’s parts, and checking the magnitude of each one of those parts. If the part is too close, it gets deleted.
for i,v in pairs(PlayerParts.Parent:GetDescendants()) do --If part is placed 10 studs near a part that doesn't want other parts, it gets deleted
if v:IsA("BasePart") then
if not v:IsDescendantOf(workspace["PlayerParts"]:FindFirstChild(Player.Name..'s Blocks')) then -- make sure player doesn't own part
if v:FindFirstChild("deleteOtherParts") then -- a check to see if that part has deleting enabled
if (part.Position - v.Position).Magnitude < 10 then -- is the part within 10 studs?
part:Destroy() --Destroy the part so it does not get created
end
end
end
end
end
This creates a noticeable replication delay which can hinder a player’s experience.
What would be a quicker way to find nearby parts?