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

How can i change the material of certain Children with ClassName?

Asked by
Shematics 117
4 years ago

Hi, i did a script that when put inside a Character, it's suppose to remove his clothes and put his skin into rock using Material, i am using a R15 Rigs so the body part are MeshPart Here's my script:

local shirt = script.Parent.Shirt
local pants = script.Parent.Pants

wait(2)
shirt.Parent = nil
pants.Parent = nil

local child = script.Parent:GetChildren()
local brick = child.Material
wait(1)
if (child.className == "MeshPart") then 
    brick = Enum.Material.Concrete
end

Weirdly, it don't seem to work, i am not a professional with script so i can't quite figure out why.

1 answer

Log in to vote
1
Answered by
Prestory 1395 Moderation Voter
4 years ago

Please provide explanation with your answers. Simply posting code does not spread knowledge of integral scripting processes which helps people understand the logic and reasoning behind your answer.

You can use IsA to check the part type

local shirt = script.Parent.Shirt
local pants = script.Parent.Pants

wait(2)
shirt.Parent = nil
pants.Parent = nil

local child = script.Parent:GetChildren()
local brick = child.Material
wait(1)
if child:IsA(“MeshPart”) then 
    brick = Enum.Material.Concrete
end

0
Thank you helpful, will use IsA instead but did i messed something else that im unaware? Shematics 117 — 4y
0
Um I don’t think so Prestory 1395 — 4y
Ad

Answer this question