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

How might you change the Player's Material and Color?

Asked by 2 years ago

local Character = game.Players.LocalPlayer.Character

for i, v in pairs(Character:GetChildren()) do

if v:IsA("Part") then

    v.Material = Enum.Material.ForceField
    v.BrickColor.Name = BrickColor.new("Institutional white")
elseif v:IsA("Hat") then

    local handle = v:WaitForChild("Handle")
    handle.Material = Enum.Material.ForceField
    handle.BrickColor.Name = BrickColor.new("Institutional white")  

end

end

That's the script I'm using for the code but it doesn't work.

0
PLEASE CHECK THE SCRIPT AGAIN, I CHANGED IT. THERE WAS AN ERROR WITH IT BECAUSE I MADE SOME TYPING ERRORS Antelear 185 — 2y

1 answer

Log in to vote
0
Answered by
Antelear 185
2 years ago
Edited 2 years ago

Here's something you can do to ease the pain:

make a Script in StarterCharacterScripts (dont make it local)

local Char = script.Parent -- the script will clone in the character and will run when it is, so make the Char variable script.Parent, as it is parented to the Character.

Char.ChildAdded:Connect(function(Child) -- this will run when a child is added into the Character.
    if Child:IsA("BasePart") then
        Child.Material = Enum.Material.ForceField
        Child.BrickColor = BrickColor.new("Institutional white")
    elseif Child:IsA("Accessory") then
        local Handle = Child:WaitForChild("Handle")
        Handle.Material = Enum.Material.ForceField
        Handle.BrickColor = BrickColor.new("Institutional white")
    end
end)

When a child is added inside of the Character, this will run. And do the checks, and everything. One thing to note is just don't change the BrickColor's name to the color you want, just use BrickColor rather than BrickColor.Name. Mark this answer if it helped you!

0
That doesn't work either weirdly since it looks like it would work properly. Spectrum99999 0 — 2y
0
Hm, let me try it. Antelear 185 — 2y
Ad

Answer this question