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

How do I Change Parts Propeties more than one in a single line in script?

Asked by 8 years ago

What I mean is Lets say If I wanna change The Player's whole body to red in script. The only I found is this

player.Character.Head.BrickColor = BrickColor.new("Really Red")

I would have to do that for legs and arm in a separate line. I don't know how do all that in just one line or find how to do it.

1 answer

Log in to vote
1
Answered by 8 years ago

If you're looking to put this in a LocalScript:

local plr = game.Players.LocalPlayer -- This line will only work in a LocalScript.
wait(1)
local prts = plr.Character:GetChildren()

for i,x in pairs(prts) do
    if x.ClassName == "Part" then
        x.BrickColor = BrickColor.new("Really red")
    end
end

Otherwise:

game.Players.PlayerAdded:connect(function(plr)
    wait(1)
    local prts = plr.Character:GetChildren()

    for i,x in pairs(prts) do
        if x.ClassName == "Part" then
            x.BrickColor = BrickColor.new("Really red")
        end
    end
end)
Ad

Answer this question