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

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

Asked by 4 years ago

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.

0
Accessories and the head don't use materials Benbebop 1049 — 4y
0
But I can still manually change them ArcanZus 61 — 4y
0
How would I make the accessories disappear then for just a while? ArcanZus 61 — 4y
0
set their transparency, see if that works Benbebop 1049 — 4y
View all comments (2 more)
0
It didn't work out ArcanZus 61 — 4y
0
`char:GetChildren("Parts")` is dumb. GetChildren doesn't take any arguments, so why did you add it> incapaz 195 — 4y

1 answer

Log in to vote
1
Answered by 4 years ago

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!

Ad

Answer this question