Resizing part based on material not working correctly

Im tryna make if a part is Marble material then set the Y size to 0.325. It isnt working im using the InCommand plugin to instantly do It and its not working heres the script.

local map = game.Workspace.Map
local parts = map:GetDescendants()

for _, part in pairs(parts) do
if part:IsA("Part") and part.Material == "Marble" then
part.Size.Y = 0.325
end
end

Have you tried using Enum.Material?

Size.Y is read-only and cannot be set I believe.

Consider doing this instead:

part.Size = Vector3.new(part.Size.X, 0.325, part.Size.Z)

It Didn’t work? 30char30char30char

Hmm, like @Keilorus said, try using Enum.Material.Marble instead.

Otherwise, it must be another issue involving the ancestry of the part.

Runtime error in InCommand script: Marble is not a valid member of “Enum.Material.Plastic”

local map = game.Workspace.Map
local parts = map:GetDescendants()

for _, part in pairs(parts) do
    if part:IsA("Part") and part.Material == Enum.Material.Marble then
        part.Size = Vector3.new(part.Size.X, 0.325, part.Size.Z)
    end
end

*If that does not work, then either the material is not set correctly or the part is not a descendant of Map.

1 Like

i forgot to add the part.Material thanks