Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I change a player's body and accessories materials?

I've tried this so far:

local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local all = char:GetChildren("Parts")

for i=1, #all do
	all[i].Material = Enum.Material.ForceField
end

This only changes the body materials, without changing the head or accessories.

6 comments

0

Accessories and the head don't use materials

0

But I can still manually change them

0

How would I make the accessories disappear then for just a while?

0

set their transparency, see if that works

0

It didn't work out

0

char:GetChildren("Parts") is dumb. GetChildren doesn't take any arguments, so why did you add it>

1 answer

✓ Accepted answer

GetChildren("Parts") doesnt need an argument, also what you're doing wrong is setting everything to a material and Humanoid & accessories dont have that property, so you can do this to check if something is a part (BasePart) and then change its material

local plr = game.Players.LocalPlayer 
local char = plr.Character or plr.CharacterAdded:Wait()
local all = char:GetDescendants() --// replace to get children if you dont want it to change every part material to force field

for i,v in pairs(all) do --// easier than doing table[i]
if v:IsA("BasePart") then
v.Material = "ForceField"
end
end

And answering your other question, "How would I make the accessories disappear then for just a while?" you can change their handle's transparency

local plr = game.Players.LocalPlayer 
local char = plr.Character or plr.CharacterAdded:Wait()
local all = char:GetChildren()
local time = 5
for i,v in pairs(all) do
if v:IsA("Accessory") then
pcall(function() v.Handle.Transparency = 1 end)
end
end
wait(time)
for i,v in pairs(all) do
if v:IsA("Accessory") then
pcall(function() v.Handle.Transparency = 0 end)
end
end

If this answered your question mark this as the answer :D!

This discussion is preserved as it was. New answers, comments, and votes are closed.