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 :(((
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 :(((
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
Works, but one thing though. It makes everything grey, not blue. Is blue just not a color?
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.
You forgot to indent your code. :P
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)
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
This discussion is preserved as it was. New answers, comments, and votes are closed.
1 comment
https://scriptinghelpers.org/questions/71/-