Sooooo, I may be using humanoids COMPLETELY wrong, but in my game I thought it would be fun to let buildings have names. They also needed to have a health system, so I figured, "Why not organize name and health with a humanoid?" All of the buildings are mesh parts, and here is a script I run at the beginning of the game:

local maps = game.ServerStorage:waitForChild("Maps"):GetChildren()
	for i, map in pairs(maps) do
		for i, building in pairs(map.Buildings:GetChildren()) do
			local buildingSize = Instance.new("IntValue")
			buildingSize.Parent = building
			buildingSize.Name = "Size"
			buildingSize.Value = building.Size.X * building.Size.Y * building.Size.X
		
			local buildingHealth = Instance.new("IntValue")
			buildingHealth.Parent = building
			buildingHealth.Name = "Health"
			buildingHealth.Value = buildingSize.Value / 10
			
			local clonedHum = Instance.new("Humanoid")
			local chance = math.random(1,3)
			if chance == 1 then
				local chance2 = math.random(1,2)
				if chance2 == 1 then
					clonedHum.Name = string.format("%s %s", prefixes[math.random(1, #prefixes)], roots[math.random(1, #roots)])
				else
					clonedHum.Name = string.format("%s %s", prefixes[math.random(1, #prefixes)], suffixes[math.random(1, #suffixes)])
				end
				
			else
				clonedHum.Name = string.format("%s %s %s", prefixes[math.random(1, #prefixes)], roots[math.random(1, #roots)], suffixes[math.random(1, #suffixes)])
			end
			
			clonedHum.Parent = building
			clonedHum.MaxHealth = buildingHealth
			clonedHum.Health = buildingHealth
			clonedHum.JumpPower = 0
			
			if clonedHum:IsA("Humanoid") then
				print(clonedHum.Name)
			end
		end
	end

I've tried changing the name display distance and such, but to no avail. Should I instead have the script create a BillBoardGui and have that show the name, and use the health value instead of the Humanoid? I just thought it may be fun to mess around with.

1 comment

0

The name GUI thats built in on anything im pretty sure. There just needs to be a part in the model called "Head" this is where the name will appear.