Overlay a textlabel on multiple parts/meshes

I’d like to achieve what’s shown on the image


I cant seem to make it work as much as i try

I tried to make a script which selects all parts touching eachother with the same value, clones them, puts them inside of a model, creates a bounding box, makes a part out of it and puts text on it.
Problem is, it can get stuck and not find any more parts touching it.

local gots = {}


local model2 = Instance.new("Model")
model2.Parent = workspace
function setText()
	table.clear(gots)
	model2:ClearAllChildren()
	for i,v in pairs(workspace.Provinces:children()) do
		if not table.find(gots, v) then
			--
			local s = v
			local f = {}
			local found = true
			repeat
				local got = false
				print(s.Name)
				local attempt = s:GetTouchingParts()
				for i,x in pairs(attempt) do
					if x:FindFirstChild("Value") and x.Value.Value == s.Value.Value then
						if not table.find(f, x) or not table.find(gots, x) then
							print(x.Name)
							table.insert(f, x)
							got = true
							table.insert(gots, x)
							s = x
						end
					end
				end
				if not got then found = false end
			until found == false
			--
			local tab = f
			local val = ""
			if #tab > 0 then
				local model = Instance.new("Model")
				model.Parent = workspace
				for i,c in pairs(tab) do
					local clone = c:Clone()
					val = clone.Value.Value
					clone:ClearAllChildren()
					clone.CanCollide = false
					clone.Parent = model
				end
				local orientation, size = model:GetBoundingBox()
				local part = Instance.new("Part")
				part.Parent = model2
				part.Size = size
				part.CFrame = orientation
				part.CanCollide = false
				part.Transparency = 1
				part.Anchored = true
				local cloning = game.ServerStorage.Text:Clone()
				cloning.Parent = part
				model:Destroy()
				cloning.TextLabel.Text = workspace.Folder[val].DisplayName.Value
			end
		end
	end
	wait(15)
	setText()
end

setText()
``'
1 Like