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)
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