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: Scripting Tutorial Help

Previous Thread :: Next Thread 
SirElander is not online. SirElander
Joined: 15 Dec 2009
Total Posts: 645
25 Dec 2012 03:00 AM
I need help with a test script. I am learning how to script for Roblox and I am starting off with a block that changes color when touched if b ==3 but everytime I join it sticks with only 1 number like 5 or 1 but never changes. Can you help?

local a = math.random(0,256)
local b = math.random(1,5)

function onTouched(h)
print(b)
if b == 3
then
script.Parent.Color = Color3.new(a, a, a)
else
print(FAILURE)
end
end
script.Parent.Touched:connect(onTouched)
Report Abuse
SmoothBlockModel is online. SmoothBlockModel
Joined: 26 Sep 2008
Total Posts: 2155
25 Dec 2012 03:07 AM
Hiya.

Okay so Im not sure if what im going to suggest is correct for what you want, But im guessing it changes once and then it just stops working, or something Similar.

Right now you have your values outside the function, So they are choosing a number once and going to keep that number everytime. You might join the game and it choose 256 and 1, And it will stay like that. To fix this just put the Variables in the function so that everytime its ran they are different! :D

function onTouched(h)
local a = math.random(0,256)
local b = math.random(1,5)
print(b)
if b == 3
then
script.Parent.Color = Color3.new(a, a, a)
else
print(FAILURE)
end
end
script.Parent.Touched:connect(onTouched)

Again, if this wasn't what you were asking for, Sorry! :x
Report Abuse
SirElander is not online. SirElander
Joined: 15 Dec 2009
Total Posts: 645
25 Dec 2012 03:13 AM
Exactly what I was asking! Thanks for the help!
Report Abuse
SmoothBlockModel is online. SmoothBlockModel
Joined: 26 Sep 2008
Total Posts: 2155
25 Dec 2012 03:15 AM
Glad to help! :D
Report Abuse
pepsimaxzero is not online. pepsimaxzero
Joined: 16 Jan 2012
Total Posts: 3535
25 Dec 2012 05:08 AM
Lol, I can't script one bit.
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