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

Help with simplifying a script?

Asked by
DevWork 80
10 years ago

Any way to simplify this script into less lines?

colour = "Really black"
local children = Workspace.Vehicles.Jeep.VehicleBody.Color:GetChildren()
for i = 1, #children do
children[i].BrickColor = BrickColor.new(colour)
end
colour = "Really black"
local children = Workspace.Vehicles.Jeep.VehicleBody.Essentials.Grill:GetChildren()
for i = 1, #children do
children[i].BrickColor = BrickColor.new(colour)
end
colour = "Really black"
local children = Workspace.Vehicles.Jeep.VehicleBody.Essentials.RearLights:GetChildren()
for i = 1, #children do
children[i].BrickColor = BrickColor.new(colour)
end
colour = "Really black"
local children = Workspace.Vehicles.Jeep.VehicleBody.Essentials.FrontLights:GetChildren()
for i = 1, #children do
children[i].BrickColor = BrickColor.new(colour)
end
colour = "Really black"
local children = Workspace.Vehicles.Jeep.VehicleBody.Essentials.Windows:GetChildren()
for i = 1, #children do
children[i].BrickColor = BrickColor.new(colour)
end
colour = "Really black"
local children = Workspace.Vehicles.Jeep.VehicleBody.Essentials.TopCover:GetChildren()
for i = 1, #children do
children[i].BrickColor = BrickColor.new(colour)
end
colour = "Really black"
local children = Workspace.Vehicles.Jeep.VehicleBody.Essentials.DoorHandles:GetChildren()
for i = 1, #children do
children[i].BrickColor = BrickColor.new(colour)
end
colour = "Really black"
local children = Workspace.Vehicles.Jeep.VehicleBody.Wheels.RBWheel:GetChildren()
for i = 1, #children do
children[i].BrickColor = BrickColor.new(colour)
end
colour = "Really black"
local children = Workspace.Vehicles.Jeep.VehicleBody.Wheels.RFWheel:GetChildren()
for i = 1, #children do
children[i].BrickColor = BrickColor.new(colour)
end
colour = "Really black"
local children = Workspace.Vehicles.Jeep.VehicleBody.Wheels.LFWheel:GetChildren()
for i = 1, #children do
children[i].BrickColor = BrickColor.new(colour)
end
colour = "Really black"
local children = Workspace.Vehicles.Jeep.VehicleBody.Wheels.LBWheel:GetChildren()
for i = 1, #children do
children[i].BrickColor = BrickColor.new(colour)
end

1 answer

Log in to vote
1
Answered by
RedCombee 585 Moderation Voter
10 years ago

You can shorten the code by using a for loop.

for a = 1,11 do
colour = "Really black"
local children = Workspace.Vehicles.Jeep.VehicleBody.Color:GetChildren()
for i = 1, #children do
children[i].BrickColor = BrickColor.new(colour)
end
end
0
Works however it's only doing it for the color and none of the others. DevWork 80 — 10y
Ad

Answer this question