Torso isn't being detected

I want to detect if the player is wearing hair and a specific Torso

The issue is it seemingly isn’t detecting the torso

I Didn’t look for solutions on the Developer Hub, because I am over 90% sure this is unique.

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

local function SeperateIds(String)
	local SeperatedStrings = {}
	local last = 1
	for i = 1, string.len(String) do
		if string.sub(String ,i, i) == "," then
			table.insert(SeperatedStrings, string.sub(String, last, i - 1))
			last = i + 1
		end
	end
	table.insert(SeperatedStrings, string.sub(String, last, -1))
	return SeperatedStrings
end

local function ApplyHairs(Player)
	local Character = Player.Character
	local Humanoid = Character:WaitForChild("Humanoid")
	local HumanoidDescription = Players:GetHumanoidDescriptionFromUserId(Player.UserId)
	local Hairs = SeperateIds(HumanoidDescription.HairAccessory)

	for i, v in pairs(Hairs) do
		local Model = InsertService:LoadAsset(v)
		local Accessory = Model:FindFirstChildOfClass("Accessory")
		local Mesh = Accessory:FindFirstChild("Handle"):FindFirstChildOfClass("SpecialMesh")
		Mesh.TextureId = "http://www.roblox.com/asset/?id=7807641103"
		Humanoid:AddAccessory(Accessory)
		Model:Destroy()
	end
end


local function ApplyTorso(Player)
	local Character = Player.Character
	local Humanoid = Character:WaitForChild("Humanoid")
	local HumanoidDescription = Players:GetHumanoidDescriptionFromUserId(Player.UserId)
	local Torso = HumanoidDescription.Torso
	local CM = script.CharacterMesh
	local CMC = CM:Clone()
	print(Torso)
	if Torso == "48474356" then
		
		CMC.Parent = Character
		print("bro has torso!")
	end
end



Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		ApplyHairs(plr)
		ApplyTorso(plr)
	end)
end)
2 Likes

Have you tried character appearance loaded?

1 Like

I have tried that now, But it still seemingly doesn’t work

In the ApplyTorso function, try doing Torso.Value because I’m thinking it’s returning a bool value.

if Torso.Value == "48474356" then
		
		CMC.Parent = Character
		print("bro has torso!")
	end

Just tried this after you suggested it, it hasn’t worked either.

You know that the Torso only applies to R6 avatars right?
R15 doesn’t have a Torso.

I’m using R6, for my script. and my game is on R6 for it’s avatars

From the Explorer window Torso isn’t a child of HumanoidDescription, it’s a child of the Player
Screenshot 2023-05-14 125030

1 Like

Wait im trying to detect this in the humanoid description
image-2
Would i need to do something like this?

local HumanoidDescription = Players:GetHumanoidDescriptionFromUserId(Player.UserId) 
local Torso = HumanoidDescription[Body Parts].Torso

I can’t test this code currently, but if it works i will update

I have found the solution after a long time.

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

local function SeperateIds(String)
	local SeperatedStrings = {}
	local last = 1
	for i = 1, string.len(String) do
		if string.sub(String ,i, i) == "," then
			table.insert(SeperatedStrings, string.sub(String, last, i - 1))
			last = i + 1
		end
	end
	table.insert(SeperatedStrings, string.sub(String, last, -1))
	return SeperatedStrings
end

local function ApplyHairs(Player)
	local Character = Player.Character
	local Humanoid = Character:WaitForChild("Humanoid")
	local HumanoidDescription = Players:GetHumanoidDescriptionFromUserId(Player.UserId)
	local Hairs = SeperateIds(HumanoidDescription.HairAccessory)

	for i, v in pairs(Hairs) do
		local Model = InsertService:LoadAsset(v)
		local Accessory = Model:FindFirstChildOfClass("Accessory")
		local Mesh = Accessory:FindFirstChild("Handle"):FindFirstChildOfClass("SpecialMesh")
		Mesh.TextureId = "http://www.roblox.com/asset/?id=7807641103"
		Humanoid:AddAccessory(Accessory)
		Model:Destroy()
	end
end


local function ApplyTorso(Player)
	local Character = Player.Character
	local Humanoid = Character:WaitForChild("Humanoid")
	local HumanoidDescription = Players:GetHumanoidDescriptionFromUserId(Player.UserId)
	local Torso = HumanoidDescription.Torso
	local CM = script.CharacterMesh
	local CMC = CM:Clone()
	print(Torso)
	if Torso == 48474356 then
	
		CMC.Parent = Character
	end
end




Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		ApplyHairs(plr)
		ApplyTorso(plr)
	end)
end)

I had the ID of the Torso in quotations. Dumb on my part but yet the solution

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.