generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Color a whole model script

Previous Thread :: Next Thread 
iNicklas is not online. iNicklas
Joined: 26 Oct 2010
Total Posts: 4031
16 Feb 2014 07:40 AM
Im working on a place, where i need the letters to change like disco colors.

Thx.

Report Abuse
DragonFox11 is not online. DragonFox11
Joined: 15 Nov 2013
Total Posts: 284
16 Feb 2014 07:41 AM
like how?
Report Abuse
KingJacko is not online. KingJacko
Joined: 20 Jun 2008
Total Posts: 3944
16 Feb 2014 08:01 AM
I can do it with a point light but not with a brick itself:


while true do
script.Parent.PointLight.Color = Color3.new(math.random(), math.random(), math.random())
wait(.2)
end
Report Abuse
dodleman is not online. dodleman
Joined: 22 Dec 2007
Total Posts: 1118
16 Feb 2014 08:02 AM
Dude stick to one topic.
Report Abuse
KingJacko is not online. KingJacko
Joined: 20 Jun 2008
Total Posts: 3944
16 Feb 2014 08:03 AM
uhmmmm it might be in the wiki let me see
Report Abuse
dodleman is not online. dodleman
Joined: 22 Dec 2007
Total Posts: 1118
16 Feb 2014 08:04 AM
while wait() do
for i,v in pairs(thing you want:GetChildren()) do
if v:IsA("BasePart") then
v.BrickColor = BrickColor.random
end
end
end

Ther
Report Abuse
BLOXLUA is not online. BLOXLUA
Joined: 16 Mar 2013
Total Posts: 453
16 Feb 2014 08:08 AM
I replied to this earlier with:

MODELNAMEHERE=game.Workspace[NAME] --Make sure the model is in the Workspace and put the model's name where "NAME" is (EX. game.Workspace["EXAMPLENAME"]); make sure to have quotations.
RANDOM=Color3.new(math.random(),math.random(),math.random())
for A,A in pairs(MODELNAMEHERE:GetChildren()) do
if A.ClassName=="Part" then
A.Color=RANDOM
else
end
end

but if you needed it to constantly changed:

while wait() do
MODELNAMEHERE=game.Workspace[NAME] --Make sure the model is in the Workspace and put the model's name where "NAME" is (EX. game.Workspace["EXAMPLENAME"]); make sure to have quotations.
RANDOM=Color3.new(math.random(),math.random(),math.random())
for A,A in pairs(MODELNAMEHERE:GetChildren()) do
if A.ClassName=="Part" then
A.Color=RANDOM
else
end
end
end
Report Abuse
dodleman is not online. dodleman
Joined: 22 Dec 2007
Total Posts: 1118
16 Feb 2014 08:09 AM
Blocks,

Nurrr...... Color3 doesn't work for brickcolors... And you can just do the same thing with less lines using what i did.
Report Abuse
lolb3 is not online. lolb3
Joined: 16 Jan 2010
Total Posts: 2268
16 Feb 2014 08:10 AM
too non-uniform

while wait() do
b = BrickColor.random
for i,v in pairs(thing you want:GetChildren()) do
if v:IsA("BasePart") then
v.BrickColor = b
end
end
end
Report Abuse
BLOXLUA is not online. BLOXLUA
Joined: 16 Mar 2013
Total Posts: 453
16 Feb 2014 08:11 AM
Your's would change ALL of the bricks in the model to DIFFERENT colors, making is quite ugly. Also, I put "A.Color=Color3.new(RANDOM)", which does work. I even tested this before hand.
Report Abuse
dodleman is not online. dodleman
Joined: 22 Dec 2007
Total Posts: 1118
16 Feb 2014 08:12 AM
He said he wants it to be disco colors.

Use mine, OP.
Report Abuse
BLOXLUA is not online. BLOXLUA
Joined: 16 Mar 2013
Total Posts: 453
16 Feb 2014 08:14 AM
In the post earlier he wanted the all of the parts in the model the same color, I don't believe he changed his mind.
Report Abuse
dodleman is not online. dodleman
Joined: 22 Dec 2007
Total Posts: 1118
16 Feb 2014 08:15 AM
[[Im working on a place, where i need the letters to change LIKE DISCO COLORS.

Thx.]]

Oh yeah? I think it did ;)
Report Abuse
iNicklas is not online. iNicklas
Joined: 26 Oct 2010
Total Posts: 4031
16 Feb 2014 10:28 AM
By Disco i meant, fully Blue, then red, then yellow and so on.
Report Abuse
COOLDUDE11OO is not online. COOLDUDE11OO
Joined: 21 Aug 2011
Total Posts: 5115
16 Feb 2014 10:32 AM
while wait(.1) do
parts = game.Workspace.Disco:GetChildren()
for i=1,#parts do
parts[i].BrickColor = math.random
end
end --Might need to remove this.
Report Abuse
TheRobloxian909 is not online. TheRobloxian909
Joined: 08 Aug 2013
Total Posts: 2444
16 Feb 2014 10:57 AM
you guys have made a big mistake.

dodle, you forgot .new() and ()

while wait() do
for i,v in pairs(thing you want:GetChildren()) do
if v:IsA("BasePart") then
v.BrickColor = BrickColor.new(random())
end
end
end

COOLDUDE, you forgot BrickColor.new() and ()

while wait(.1) do
parts = game.Workspace.Disco:GetChildren()
for i=1,#parts do
parts[i].BrickColor = BrickColor.new(math.random(),math.random(),math.random())
end
end --
Report Abuse
InternalRecursion is not online. InternalRecursion
Joined: 30 Dec 2012
Total Posts: 349
16 Feb 2014 11:08 AM
while Wait()do
local c = Color3.new(math.random(0,1),math.random(0,1),math.random(0,1))
for i,v in pairs(MODEL:GetChildren())do
v.Color = c
end end
Report Abuse
InternalRecursion is not online. InternalRecursion
Joined: 30 Dec 2012
Total Posts: 349
16 Feb 2014 11:10 AM
Mine Works g00d.
Report Abuse
InternalRecursion is not online. InternalRecursion
Joined: 30 Dec 2012
Total Posts: 349
16 Feb 2014 11:12 AM
while Wait()do
local c = Color3.new(math.random(0,1),math.random(0,1),math.random(0,1))
if c.r == 0 or c.g == 0 or c.b == 0 then
c = Color3.new(0,0,1)
end
for i,v in pairs(Model:GetChildren())do
if v:IsA("BasePart")then
v.Color = c
end end end
Report Abuse
InternalRecursion is not online. InternalRecursion
Joined: 30 Dec 2012
Total Posts: 349
16 Feb 2014 11:13 AM
k final one, s0rry, it's late here.


while Wait()do
local c = Color3.new(math.random(0,1),math.random(0,1),math.random(0,1))
if c.r == 0 and c.g == 0 and c.b == 0 then
c = Color3.new(0,0,1)
end
for i,v in pairs(Model:GetChildren())do
if v:IsA("BasePart")then
v.Color = c
end end end
Report Abuse
Gorake is not online. Gorake
Joined: 10 Feb 2014
Total Posts: 219
16 Feb 2014 11:51 AM
Lol I decided to do this super complicated.
Basically, this script uses hue instead of randomly setting RGB so you always get a bright color. Oh, and it supports multiple child-levels and changing ancestry.
Easier ways to do this? Of course. Change the first 2 lines to your liking.

local model = Workspace.Model -- Replace, obviously
local waittime = 0.5 -- Lower numbers = more epileptic

local children = {}

local function Recurse(obj)
for _,v in pairs(obj:GetChildren()) do
if v:IsA("BasePart") then
table.insert(children,v)
end
Recurse(v)
end
end

Recurse(model)

model.DescendantAdded:connect(function(child) if child:IsA("BasePart") then table.insert(children,child) end end)
model.DescendantRemoving:connect(function(child)
for i = 1,#children do
if children[i] == child then
children[i] = nil
end
end
end)

while wait(waittime) do
local h = math.random(0,360)
local x = 1-math.abs((h/60)%2-1)
local color = h<60 and Color3.new(1,x,0) or h<120 and Color3.new(x,1,0) or h<180 and Color3.new(0,1,x) or h<240 and Color3.new(0,x,1) or h<300 and Color3.new(x,0,1) or Color3.new(1,0,x)
for i = 1,#children do
children[i].BrickColor = BrickColor.new(color)
end
end
Report Abuse
SFOH is not online. SFOH
Joined: 01 Nov 2009
Total Posts: 293
16 Feb 2014 11:55 AM
You all are making this too complicated
Just use BrickColor.Random()
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
16 Feb 2014 11:55 AM
modeluwannacolor = Workspace.ModelNameHere

function colorme()
for a,b in pairs(modeluwannacolor:GetChildren()) do
if b:IsA ("BasePart") then
b.BrickColor = color
end
end
end)
while wait(2) do

color = math.random(3)

if color == 1 then
color = BrickColor.new("Really blue")
colorme()

elseif color == 2 then
color = BrickColor.new("Really red")
colorme()

elseif color == 3 then
color = BrickColor.new("New Yeller")
colorme()
end
end
Report Abuse
Gorake is not online. Gorake
Joined: 10 Feb 2014
Total Posts: 219
16 Feb 2014 11:57 AM
Yes, SFOH, it was overly complicated, but 'just using' BrickColor.Random() has a few problems:
1) You need to access all of the children of a model, which is why I used a recursive function
2) BrickColor.Random() includes faded and grayscale colors, which isn't very disco-esque
3) It's not as fun
Report Abuse
shadownetwork is not online. shadownetwork
Joined: 06 Feb 2014
Total Posts: 296
16 Feb 2014 12:29 PM
@dodleman Color3 Values do work as BrickColors
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image