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 » Scripters
Home Search
 

Re: Simple script practice

Previous Thread :: Next Thread 
supperayman is not online. supperayman
Joined: 08 Apr 2011
Total Posts: 296
29 Mar 2016 08:14 AM
Hi I'm new to scripting and have learned much of the basics from wiki and all...
And now I want to put my knowledge that I have so far to the test by creating a simple script of something. Can you guys leave a suggestion on what I should script?
Report Abuse
Lord_Oscar is not online. Lord_Oscar
Joined: 15 Nov 2009
Total Posts: 17662
29 Mar 2016 08:15 AM
when you click a brick, make it change to a random color?


It's simple physics R$143
Report Abuse
Royal_Zey is not online. Royal_Zey
Joined: 25 Mar 2016
Total Posts: 233
29 Mar 2016 08:20 AM
--If you fail, here's the code to make the random colored brick, it could've been way simpler but yeah consider it as a function lel

local Brick = game.Workspace.Part;

function RandomColor(Obj)
math.randomseed(tick())
local RandR,RandG,RandB=math.random(),math.random(),math.random()
Obj.BrickColor = Color3.new(RandR,RandG,RandB)
print(RandR,RandG,RandB.." are the new Color3 values for "..Obj.Name.."'s BrickColor")
end

Brick.Touched:connect(function()
RandomColor(Brick)
end)
Report Abuse
ExtremeBuilder15 is not online. ExtremeBuilder15
Joined: 01 May 2012
Total Posts: 3176
29 Mar 2016 08:28 AM
Or you could do:

local Brick = game.workspace.Part

function ChangeColor(Obj)
local Number = math.random(1,355)
Obj.BrickColor = BrickColor.new(Color3.new(Number,Number,Number))
end


Brick.Touched:connect(ChangeColor)
Report Abuse
AbstractMadness is not online. AbstractMadness
Joined: 22 Dec 2014
Total Posts: 20425
29 Mar 2016 08:32 AM
or...

brick.Touched:connect(function() brick.BrickColor = BrickColor.random() end)



#code R+ | local RAP = "R$383,771"; local robux = "R$1,982"
Report Abuse
Royal_Zey is not online. Royal_Zey
Joined: 25 Mar 2016
Total Posts: 233
29 Mar 2016 08:34 AM
@Extreme

2 things

1) if the number is above 255 then, well yeah lol.
2) you're using the same number in R,G and B so it'll return white xd
Report Abuse
supperayman is not online. supperayman
Joined: 08 Apr 2011
Total Posts: 296
29 Mar 2016 08:44 AM
Well I did this:

local part = script.Parent

function onClicked()
part.BrickColor = BrickColor.Random()
end

part.ClickDetector.MouseClick:connect(onClicked)

Seeing these script: They're more complex than this xD. But I can understand it (Kinda).
Report Abuse
ExtremeBuilder15 is not online. ExtremeBuilder15
Joined: 01 May 2012
Total Posts: 3176
29 Mar 2016 08:47 AM
@Royal lol, waking up and being tired are two worst things when scripting....







except for coffee spills ;p
Report Abuse
supperayman is not online. supperayman
Joined: 08 Apr 2011
Total Posts: 296
29 Mar 2016 09:51 AM
@Royal_Zay your script somehow failed with: "Obj.Brickcolor = Color3.new(RandR,RandG,RandB)"
Changin Color3 to BrickColor seems to fix it...

(So: "Obj.BrickColor = BrickColor.new(RandR,RandG,RandB)"
Report Abuse
Protoduction is not online. Protoduction
Joined: 27 Jul 2012
Total Posts: 1054
29 Mar 2016 09:57 AM
You noobs might use 0-255, but Color3 goes from 0 to 1

local r = math.random(0,255)
local g = math.random(0,255)
local b = math.random(0,255)
local color = BrickColor.new(Color3.new(r/255,g/255,b/255))

All of that is unnescascery however as

BrickColor.Random()

exist..
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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