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: math.random

Previous Thread :: Next Thread 
KCNx12 is not online. KCNx12
Joined: 09 Jul 2008
Total Posts: 3230
27 Sep 2012 02:46 PM
I am one of the most amateur scripters, and I need help with this script here:

Workspace.ColorChanger.Script:18: 'end' expected (to close 'function' at line 1) near eof

function onHit(hit)
wait(1)
print("Is this going to work? :o")
while true do
Num = math.random(1,3)
if Num == 1 then
script.Parent.BrickColor = Color3.new("Bright red")
end
if Num == 2 then
script.Parent.BrickColor = Color3.new("Bright blue")
end
if Num == 3 then
script.Parent.BrickColor = Color3.new("Bright green")
end
end

script.Parent.Touched:connect(onHit)
Report Abuse
Robert00001 is not online. Robert00001
Joined: 15 May 2010
Total Posts: 7965
27 Sep 2012 02:50 PM
Missed an end.

function onHit(hit)
wait(1)
print("Is this going to work? :o")
while true do
Num = math.random(1,3)
if Num == 1 then
script.Parent.BrickColor = Color3.new("Bright red")
end
if Num == 2 then
script.Parent.BrickColor = Color3.new("Bright blue")
end
if Num == 3 then
script.Parent.BrickColor = Color3.new("Bright green")
end
end
end

script.Parent.Touched:connect(onHit)

~ ROBERT00001 ~
~(ಠωಠ)~
Report Abuse
Fedorakid is not online. Fedorakid
Joined: 17 Jul 2010
Total Posts: 7079
27 Sep 2012 02:50 PM
I dont get this script, what is it supposed to do?
Report Abuse
blackboy167thst is not online. blackboy167thst
Joined: 22 Jul 2011
Total Posts: 2468
27 Sep 2012 03:14 PM
@Robert, you too missed an end.

function onHit(hit)
wait(1)
print("Is this going to work? :o")
while true do
Num = math.random(1,3)
if Num == 1 then
script.Parent.BrickColor = Color3.new("Bright red")
end
if Num == 2 then
script.Parent.BrickColor = Color3.new("Bright blue")
end
if Num == 3 then
script.Parent.BrickColor = Color3.new("Bright green")
end
end
end
end

script.Parent.Touched:connect(onHit)
Report Abuse
Robert00001 is not online. Robert00001
Joined: 15 May 2010
Total Posts: 7965
27 Sep 2012 03:21 PM
NOPE
ಠ_ಠ

~ ROBERT00001 ~
~(ಠωಠ)~
Report Abuse
blackboy167thst is not online. blackboy167thst
Joined: 22 Jul 2011
Total Posts: 2468
27 Sep 2012 03:28 PM
Yesh.
Report Abuse
Robert00001 is not online. Robert00001
Joined: 15 May 2010
Total Posts: 7965
27 Sep 2012 03:30 PM
TESTED

NO SYNTAX ERRORS OCCURED TO MINE

~ ROBERT00001 ~
~(ಠωಠ)~
Report Abuse
MonkeyForBananas is not online. MonkeyForBananas
Joined: 17 Sep 2012
Total Posts: 52
27 Sep 2012 03:32 PM
Oh, my bad. Didn't see the whole thing. I was just counting the if's and the function. Sorry :I
Report Abuse
XxChopSlaperxX is not online. XxChopSlaperxX
Joined: 09 Nov 2010
Total Posts: 3112
27 Sep 2012 03:33 PM
function onHit(hit) -- 1 end
wait(1)
print("Is this going to work? :o")
while true do - 2 end
Num = math.random(1,3)
if Num == 1 then
script.Parent.BrickColor = Color3.new("Bright red")
end
if Num == 2 then
script.Parent.BrickColor = Color3.new("Bright blue")
end
if Num == 3 then
script.Parent.BrickColor = Color3.new("Bright green")
end
end -- 2 end
end -- 1 end


Robert wins
Report Abuse
blackboy167thst is not online. blackboy167thst
Joined: 22 Jul 2011
Total Posts: 2468
27 Sep 2012 03:34 PM
Monkey just took the whole thought out of my head. o_o
Report Abuse
Xlaive is not online. Xlaive
Joined: 25 Aug 2012
Total Posts: 97
27 Sep 2012 04:00 PM
function onHit(hit)
wait(1)
local Num = math.random(3)
if Num == 1 then
script.Parent.BrickColor = BrickColor.new("Bright red")
elseif Num == 2 then
script.Parent.BrickColor = BrickColor.new("Bright blue")
elseif Num == 3 then
script.Parent.BrickColor = BrickColor.new("Bright green")
end
end
script.Parent.Touched:connect(onHit)
Report Abuse
ElectricBlaze is not online. ElectricBlaze
Joined: 18 Jul 2011
Total Posts: 22930
27 Sep 2012 04:15 PM
Whoa, Robert, I haven't seen you here in a while. Over a year, in fact. :o

http://wiki.roblox.com/index.php/User:ElectricBlaze
Report Abuse
rayoma is not online. rayoma
Joined: 13 Nov 2009
Total Posts: 1911
27 Sep 2012 05:34 PM
You don't need the while loop in there or it will just cause a stack overflow error. Also you need to change the `Color3.new` to `BrickColor.new`
Report Abuse
MonkeyForBananas is not online. MonkeyForBananas
Joined: 17 Sep 2012
Total Posts: 52
27 Sep 2012 06:31 PM
Hooplah!

http://www.roblox.com/The-Roblox-Quiz-place?id=93016262 Checkout The Roblox Quiz!™, PM me any suggestions or questions you want me to add. It's still not finish.
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