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
We use cookies to offer you a better experience. By using Roblox.com, you are agreeing to our Privacy and Cookie Policy.
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Table help

Previous Thread :: Next Thread 
Blacksun1998 is not online. Blacksun1998
Joined: 06 Aug 2013
Total Posts: 59
20 May 2014 01:52 PM
colors = {"Bright Red", "really blue", "new yeller", "lime green", "Bright Violet", "Neon Orange"}

for i,v in pairs(game.Workspace.Plates:GetChildren()) do
if v:IsA("Part") then
v.BrickColor = BrickColor.new(colors[math.random(1,6)])
end
end

How can I access my Colors from my table?
how can I randomly choose what my brick color will be?

i have a 10x10 field of bricks and i want to color them :)
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
20 May 2014 02:22 PM
Use ipairs, and make sure the capitals are correct
Report Abuse
1MangoMan0 is not online. 1MangoMan0
Joined: 28 Sep 2010
Total Posts: 1596
20 May 2014 02:36 PM
Looks like that should work to me, but I'd use IsA("BasePart") instead, also warspyking is correct. Make sure everything is correctly spelled and capitalized or it won't work right.
Report Abuse
FreeScriptMaker is not online. FreeScriptMaker
Joined: 29 Nov 2013
Total Posts: 2275
20 May 2014 02:38 PM
"Use ipairs"
There is no reason he should need to use ipairs.
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
20 May 2014 02:44 PM
The wiki reccomends it. There's your reason
Report Abuse
1MangoMan0 is not online. 1MangoMan0
Joined: 28 Sep 2010
Total Posts: 1596
20 May 2014 02:45 PM
The wiki also says that tick() returns UNIX time only to say later that the returned value could change depending on the server's time zone.
Report Abuse
FreeScriptMaker is not online. FreeScriptMaker
Joined: 29 Nov 2013
Total Posts: 2275
20 May 2014 02:46 PM
Just because the wiki recommends it doesn't mean it is correct and I doubt you could even describe the difference between pairs and ipairs.
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
20 May 2014 02:48 PM
UNIX time depends on your location, so yes the wiki is correct there.


As for pairs and ipairs, if the wiki reccomends it, then it is best to use it, the wiki hasn't been wrong in a while.
Report Abuse
1MangoMan0 is not online. 1MangoMan0
Joined: 28 Sep 2010
Total Posts: 1596
20 May 2014 03:01 PM
Unix time is the amount of seconds that have passed since January 1st 1970, UTC. Unless I'm missing something, time zones can't change how many seconds have passed since a certain time under a defined time zone.
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
20 May 2014 03:04 PM
Oh and by the way. I do know the difference between pairs and ipairs.

pairs iterates through at no particular order. It acts as if the table is a dictionary.

ipairs does it in order, and acts as if the table is an array.


Happy?
Report Abuse
Azureous is not online. Azureous
Joined: 29 Jan 2012
Total Posts: 25287
20 May 2014 03:05 PM
ipairs is different s.t. it stops pairing the index with the value when it finds a nil value...
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
20 May 2014 03:07 PM
@1mango

Depending on the time zone, the seconds are different, because the times are different, so seconds past are different.

Also, the servers are in different time zones, so that will change as well.
Report Abuse
swimguy777 is not online. swimguy777
Joined: 30 May 2009
Total Posts: 17092
20 May 2014 03:16 PM
@war
"UNIX time depends on your location"

False. Copied directly from the Wikipedia article:
"Unix time (aka POSIX time or Epoch time), is a system for describing instants in time, defined as the number of seconds that have elapsed since 00:00:00 Coordinated Universal Time (UTC), Thursday, 1 January 1970"

The UTC is a fancy way of saying GMT, which is the Greenwich Mean Time, a timezone surrounding Iceland and the British isles. UNIX time returns the number of seconds passed since 1 January 1970 in this timezone.

-[::ƧѡÎḾḠΰῩ::]-[::Helper of Scripting and Writer of Wikis::]
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
20 May 2014 03:22 PM
First of all, anybody can make a Wikipedia article. That info is as dependable as from ask . com


Second, roblox does stuff differently sometimes. Ask me, I have no idea, but in roblox, UNIX time DOES depend on you location.
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
20 May 2014 03:24 PM
Oh and don't use " unless your quoting something/someone

I never said what was in the quotation marks you made. I never even said location.
Report Abuse
swimguy777 is not online. swimguy777
Joined: 30 May 2009
Total Posts: 17092
20 May 2014 03:31 PM
@blacksun

Your script was correct except for the names of the colors. You need to make sure that the capitalization of the words is correct or else it will default to Medium stone grey.

Here's your list of colors with correct capitalization:

colors = {"Bright red", "Really blue", "New Yeller", "Lime green", "Bright violet", "Neon orange"}


-[::ƧѡÎḾḠΰῩ::]-[::Helper of Scripting and Writer of Wikis::]
Report Abuse
swimguy777 is not online. swimguy777
Joined: 30 May 2009
Total Posts: 17092
20 May 2014 03:32 PM
@war

Yes you did, your 3rd comment. I copied and pasted it.

-[::ƧѡÎḾḠΰῩ::]-[::Helper of Scripting and Writer of Wikis::]
Report Abuse
swimguy777 is not online. swimguy777
Joined: 30 May 2009
Total Posts: 17092
20 May 2014 03:37 PM
@war

You are partially correct. When you use tick() in a LocalScript it will return the user's local time, while using it in a Script will return the standard UNIX time.

http://wiki.roblox.com/index.php?title=Time#tick

-[::ƧѡÎḾḠΰῩ::]-[::Helper of Scripting and Writer of Wikis::]
Report Abuse
nighttimeninja314 is not online. nighttimeninja314
Joined: 04 Apr 2011
Total Posts: 4001
20 May 2014 03:39 PM
colors = {"Bright red", "Really blue", "New yeller", "Lime green", "Bright violet", "Neon orange"}
Report Abuse
Blacksun1998 is not online. Blacksun1998
Joined: 06 Aug 2013
Total Posts: 59
21 May 2014 06:03 AM
well thanks for help
but i solved it this way

colors = {21,24,37,23,1016,104}
colorstext = {"red", "yellow", "green", "blue", "pink", "purple"} -- "bright red", "bright yellow", "bright green", "bright blue", "pink", "bright violet"

for turns=10,0,-1 do

for i,v in pairs(game.Workspace.Plates:GetChildren()) do
if v:IsA("Part") then
v.BrickColor = BrickColor.new(colors[math.random(1,6)])
end
end

randcolor = math.random(1,6)
print(colorstext[randcolor])
for time=turns,0,-1 do
print(time)
end

for i,v in pairs(game.Workspace.Plates:GetChildren()) do
if v:IsA("Part") and v.BrickColor.number ~= randcolor then
v.CanCollide = false
v.Transparency = 1
end
end

wait(2)

for i,v in pairs(game.Workspace.Plates:GetChildren()) do
if v:IsA("Part") and v.BrickColor.number ~= randcolor then
v.CanCollide = true
v.Transparency = 0
end
end
end

but now i have the problem that ALL my parts go transparant and cancollide
why? if i do v.BrickColor.number ~= randcolor then the blocks that have the random color disappear. but i want that ony the color that is chosen that only that one color stays and all the other colorblocks disapear
Report Abuse
Blacksun1998 is not online. Blacksun1998
Joined: 06 Aug 2013
Total Posts: 59
21 May 2014 06:18 AM
derp... i fixed it

i did if v:IsA("Part") and v.BrickColor.Number ~= randcolor then

it had to be if v:IsA("Part") and v.BrickColor.Number ~= colors[randcolor] then
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