Hey
I was wondering how I could turn clothes into a mesh for a tool.
Thanks
Hey
I was wondering how I could turn clothes into a mesh for a tool.
Thanks
To turn a Roblox shirt or pants into a mesh, you can use the Mesh
object in the Roblox API. Here is an example of how you could use it:
Mesh
object as a child of the shirt or pants you want to turn into a mesh.CreateFromAssetId
function of the Mesh
object to set the asset ID of the shirt or pants as the mesh’s asset ID.MeshType
property of the Mesh
object to Enum.MeshType.FileMesh
.Scale
property of the Mesh
object to the desired size of the mesh.Here is an example of how this could look in code:
local shirt = game.Workspace.Shirt
local mesh = Instance.new("Mesh")
mesh.Parent = shirt
mesh.CreateFromAssetId(shirt.AssetId)
mesh.MeshType = Enum.MeshType.FileMesh
mesh.Scale = Vector3.new(1, 1, 1)
Keep in mind that this will only work for shirts and pants that have a mesh asset associated with them. If the shirt or pants only have a texture, this method will not work.
Hi! Thanks for the help but how would I know if clothing has a mesh attached to it?
local shirt = script.Parent
local mesh = shirt.Mesh
if mesh ~= nil then
print(“The shirt has a mesh attached to it”)
else
print(“The shirt does not have a mesh attached to it”)
end
This script would error if shirt.Mesh
doesn’t exist. Use local mesh = shirt:FindFirstChildWhichIsA("Mesh")
instead. (i’m assuming mesh is a child of the clothing, am i wrong?)