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

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

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.

1 comment

0

PLEASE CHECK THE SCRIPT AGAIN, I CHANGED IT. THERE WAS AN ERROR WITH IT BECAUSE I MADE SOME TYPING ERRORS

1 answer

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!

2 comments

0

That doesn't work either weirdly since it looks like it would work properly.

0

Hm, let me try it.

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