Trying to make a player body part outline

im trying to give avatar body parts an outline so players can see the exact size of specific bundle body parts (a viewable hitbox, basically) im wanting it to look like this:
image
(this is me selecting my avatar’s body parts in studio)

i have no idea how to go about doing this, i have looked at gears that do stuff similar [Lightning Wand, Hyperlaser Gun, etc] but im not not sure how to implement the part im wanting from the gear into the experience. i have also tried to find a forum post about this but i couldn’t find what i was looking for.

Not sure what you mean exactly but have you looked into Highlights or Selection box?

Edit: Reading through the OP again, you should use selection box to get your desired outcome.

@TheDCraft is right here is example code using that:

for _, child in pairs(script.Parent:GetChildren()) do
	if child:IsA('BasePart') and child.Name ~= 'HumanoidRootPart' then
		local box = Instance.new('SelectionBox')
		
		box.Color3 = Color3.fromRGB(0, 170, 255)
		box.LineThickness = 0.02
		
		box.Adornee = child
		box.Parent = child
	end
end

(Local script in StarterCharacterScripts)

1 Like

Do you want Players to See ONLY Their outlines or other players outlines too?

preferably people being able to view each other’s outlines

Then you will need something like this:

local Players = game:GetService('Players')

Players.PlayerAdded:Connect(function(player)
    local character = player.Character or player.CharacterAdded:Wait()

    for _, child in pairs(character:GetChildren()) do
        if child:IsA('BasePart') and child.Name ~= 'HumanoidRootPart' then
            local box = Instance.new('SelectionBox')

            box.Color3 = Color3.fromRGB(0, 170, 255)
            box.LineThickness = 0.02

            box.Adornee = child
            box.Parent = child
        end
    end
end)

(Script in ServerScriptService)

this works exactly how i want it to in r6 but only has a SelectionBox for the head in r15

Strange, for me it works just fine:
image

You can try changing this line:

if child:IsA('BasePart') and child.Name ~= 'HumanoidRootPart' the

to this:

if (child:IsA('BasePart') or child:IsA('Part')) and child.Name ~= 'HumanoidRootPart' then

but I’m not sure if it’s gonna help.

its working exclusively for the blocky avatar type it seems
image

Ok so i found a solution, replace this

if child:IsA('BasePart') and child.Name ~= 'HumanoidRootPart' then

with this:

if (child:IsA('MeshPart') or child:IsA('BasePart')) and child.Name ~= 'HumanoidRootPart' then

However there is one more problem because you will heave to delay script until mesh part is loaded otherwise selection box won’t spawn. To fix this you could simply place wait(3) before for loop but that’s not the best solution. So i recommend using this code:

local Players = game:GetService('Players')

Players.PlayerAdded:Connect(function(player)
	player.CharacterAppearanceLoaded:Connect(function() --Here we wait until all meshes are loaded
		local character = player.Character or player.CharacterAdded:Wait()

		for _, child in pairs(character:GetChildren()) do		
			if (child:IsA('MeshPart') or child:IsA('BasePart')) and child.Name ~= 'HumanoidRootPart' then
				local box = Instance.new('SelectionBox')

				box.Color3 = Color3.fromRGB(0, 170, 255)
				box.LineThickness = 0.02

				box.Adornee = child
				box.Parent = child
			end
		end
	end)
end)

Hope it helps! :slight_smile:

2 Likes

The ‘BasePart’ class is the base class for all ‘Part’ classes, the ‘MeshPart’, ‘UnionPart’, ‘Part’ and other classes are derived from it, IsA("BasePart") alone should suffice.

local Game = game
local Players = Game:GetService("Players")

local function OnPlayerAdded(Player)
	local function OnCharacterAdded(Character)
		if not Player:HasAppearanceLoaded() then Player.CharacterAppearanceLoaded:Wait() end
		for _, Child in ipairs(Character:GetChildren()) do
			if not (Child:IsA("BasePart")) then continue end
			local SelectionBox = Instance.new("SelectionBox")
			SelectionBox.Adornee = Child
			--Set 'SelectionBox' properties here.
			SelectionBox.Parent = Child
		end
	end

	Player.CharacterAdded:Connect(OnCharacterAdded)
end

Players.PlayerAdded:Connect(OnPlayerAdded)