|
| 27 Jul 2015 11:17 AM |
I already renamed all the recolorable car parts to V and my current method is that each V has this script in them.
while wait (1) do script.Parent.BrickColor = script.Parent.Parent.Vealik.BrickColor end
The method is that all the V named parts have this script in them which turns them into the color of the brick named Vealik, but the problem is that this method is filled with loops and causes lag because there are about atleast 20 recolorable parts in the car and there are a lot of cars in the game. |
|
|
| Report Abuse |
|
|
|
| 27 Jul 2015 11:21 AM |
One script in the car. I am assuming this:
-Workspace
--Car MODEL ---V ---Script ---V ---Part ---V
local Vealik = WHEREVER VEALIK IS.
Vealik.Changed:connect(function() for i, v in next, script.Parent:GetChildren() do if v.Name == "V" and v:IsA("BasePart") then v.BrickColor = Vealik.BrickColor; end end end)
Enjoying your stay at the Scripters Forum? Join this! http://www.roblox.com/My/Groups.aspx?gid=2582784 |
|
|
| Report Abuse |
|
|
ByDefault
|
  |
| Joined: 25 Jul 2014 |
| Total Posts: 3197 |
|
|
| 27 Jul 2015 11:21 AM |
for i,v in pairs(CarModel:GetChildren()) do v.BrickColor = BrickColor.new("White") end |
|
|
| Report Abuse |
|
|
notfruit
|
  |
| Joined: 21 Sep 2012 |
| Total Posts: 1386 |
|
|
| 27 Jul 2015 11:25 AM |
Don't use a loop nub, make one script and do this:
parts = something.something:getChildren() -- use this probably to get parts
use script.Parent.Vealik.Changed:connect(function(property) -- if property is BrickColor, change color of all parts in the table "parts" end)
Here: http://wiki.roblox.com/index.php?title=API:Class/Instance/Changed |
|
|
| Report Abuse |
|
|
|
| 27 Jul 2015 11:25 AM |
Sorry but you have just made a major mistake, having that many parts that change collor and each with their own script will cause major lag. Instead, use a for loop: while wait(1) do for i, v in pairs (script.Parent:GetChildren()) do if v.Name=="V" then v.BrickColor=game.Workspace.Vealik.BrickColor end end end
Put this in each car, this will help allot with the lag than just having a script for every part. |
|
|
| Report Abuse |
|
|
| |
|