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

How to make this script turn everything blue in the workspace?

Asked by 7 years ago

It's supposed to make everything in the workspace blue, but nothing happens!

function underwater()
    local children = game.Workspace:GetChildren()
    children.BrickColor3 = "Blue"
end

this is probably a stupid mistake, don't hate :(((

3 answers

Log in to vote
2
Answered by
Dominical 215 Moderation Voter
7 years ago

Use a for loop to "go through" each child of the workspace and check if it is a part. If it is then we can color it blue. Also, instead of "BrickColor3" you would just say "BrickColor." Another problem is that you have to set a brick color to a brick color. Just saying "Blue" is a string. To create a BrickColor, you do this: BrickColor.new("Blue")

Anyways, here's how I would do it. Like this:

for i,v in pairs(workspace:GetChildren()) do
if v:IsA("Part") then
v.BrickColor=BrickColor.new("Blue")
end
end
0
Works, but one thing though. It makes everything grey, not blue. Is blue just not a color? MustangHeart 67 — 7y
0
You have to be more specific with the color of blue. Instead of saying 'BrickColor.new("Blue"), you can do either 'BrickColor.Blue()' or 'BrickColor.new("Bright blue")'. Note that the first option is actually a basic brickcolor constructor and doesn't work for most colors. Uglypoe 557 — 7y
0
You forgot to indent your code. :P TheeDeathCaster 2368 — 7y
Ad
Log in to vote
0
Answered by
4D_X 118
7 years ago

Dominical, your script only changes colors of parts. Not parts in models, folders, etc. Here's the script that will change the color OF EVERY BRICK BLUE.

function ColorAll(a)
for n,o in pairs(a:GetChildren())do
if(o:IsA("BasePart"))then o.BrickColor = BrickColor.new('Bright blue') end
ColorAll(o)
end
end

ColorAll(workspace)
Log in to vote
0
Answered by
commag 228 Moderation Voter
7 years ago

So, saying GetChildren() creates a table, meaning you have to treat it like one

function underwater()
local Parts = game.Workspace:GetChildren()
for i, v in pairs(Parts)
if v:IsA("Part") then 
v.BrickColor = BrickColor.new("Really blue")
end
end

Answer this question