Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Cloning Decals to all sides of a part?

Asked by 5 years ago

So I have this here that runs in the command bar which replaces a torso mesh (now deprecated) into a block and two wedges. I run this code in the command bar. The script works fine by itself but I need decals to be applied on all sides on the new block and wedges because the game cannot work well without them. How do I link a decal to it and apply it to all sides of all newly created parts?

local properties = {
    "Size","CFrame","Color","Material","Anchored","Locked","CanCollide",
    "Transparency","Reflectance","Archivable","CollisionGroupId",
    "CustomPhysicalProperties","TopSurface","BottomSurface","LeftSurface",
    "RightSurface","FrontSurface","BackSurface"
}
function copyApperance(part1, part2)
    for _,property in pairs(properties) do
        part2[property] = part1[property]
    end
end

function convertTorsoMeshToPart(torso)
    local middle = Instance.new("Part")
    local wedge1,wedge2 = Instance.new("WedgePart"), Instance.new("WedgePart")
    copyApperance(torso, middle)
    copyApperance(torso, wedge1)
    copyApperance(torso, wedge2)

    local middleWidth = torso.Size.X - torso.Size.Z*0.6
    middle.CFrame = torso.CFrame
    middle.Size = Vector3.new(torso.Size.X - torso.Size.Z*0.6, torso.Size.Y, torso.Size.Z)
    wedge1.Size = Vector3.new(torso.Size.Z,torso.Size.Y,torso.Size.Z*0.3)
    wedge1.CFrame = torso.CFrame * CFrame.Angles(0,math.pi/2,0) * CFrame.new(0,0,-(middle.Size.X/2+wedge1.Size.Z/2))
    wedge2.Size = Vector3.new(torso.Size.Z,torso.Size.Y,torso.Size.Z*0.3)
    wedge2.CFrame = torso.CFrame * CFrame.Angles(0,-math.pi/2,0) * CFrame.new(0,0,-(middle.Size.X/2+wedge2.Size.Z/2))
    middle.Parent = torso.Parent
    wedge1.Parent = torso.Parent
    wedge2.Parent = torso.Parent

    torso:Destroy()
end

print("Starting")
for _,v in pairs(game:GetDescendants()) do
    pcall(function()
        if v:IsA("SpecialMesh") and v.MeshType == Enum.MeshType.Torso then
            convertTorsoMeshToPart(v.Parent)
        end
    end)
end
print("Done")
0
MeshType.Torso is deprecated User#19524 175 — 5y
1
thats why he's converting them the8bitdude11 358 — 5y
1
sorry User#19524 175 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

a quick script i put together:

local texture = TEXTUREIDHERE
local part = PARTHERE
local decal = Instance.new("Decal")
decal.Texture = texture or "rbxassetid://"..texture or "rbxasset://"..texture
local decal2 = decal:Clone()
local decal3 = decal:Clone()
local decal4 = decal:Clone()
local decal5 = decal:Clone()
local decal6 = decal:Clone()
decal.Face = Enum.NormalId.Back
decal2.Face = Enum.NormalId.Bottom
decal3.Face = Enum.NormalId.Front
decal4.Face = Enum.NormalId.Left
decal5.Face = Enum.NormalId.Right
decal6.Face = Enum.NormalId.Top
decal.Parent = part
decal2.Parent = part
decal3.Parent = part
decal4.Parent = part
decal5.Parent = part
decal6.Parent = part
0
really hacky method to do it the8bitdude11 358 — 5y
0
what would the part be exactly? All generated parts? TheLionLiar 39 — 5y
0
well, if the decals are going on every part it creates then yes and you could add for i = 0,3 do to it the8bitdude11 358 — 5y
Ad

Answer this question