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: Why won't this simple script work?

Previous Thread :: Next Thread 
Tonitoni is not online. Tonitoni
Joined: 14 Mar 2009
Total Posts: 6429
12 Jul 2012 07:06 AM
local Head=script.Parent
local Model=script.Parent.Parent

function OnClick()

local Num1=math.random(1,9)
local Num2=math.random(1,9)
local Num3=math.random(1,9)
local Num4=math.random(1,9)
local Num5=math.random(1,9)

local Number=Num1 .. Num2 .. Num3 .. Num4 .. Num5

Model.Name=Number

end

Head.ClickDetector.MouseClick:connect(onClick)
Report Abuse
AdvorsusDuo is not online. AdvorsusDuo
Joined: 17 May 2012
Total Posts: 5265
12 Jul 2012 07:07 AM
Well what seems to be the problem? Any output? ;)

-Nick
Report Abuse
Tonitoni is not online. Tonitoni
Joined: 14 Mar 2009
Total Posts: 6429
12 Jul 2012 07:12 AM
14:11:34 - attempt to call a nil value
14:11:34 - Disconnected event because of exception
Report Abuse
triston220 is not online. triston220
Joined: 08 Mar 2010
Total Posts: 1861
12 Jul 2012 07:12 AM
Head.ClickDetector.MouseClick:connect(OnClick)

Function calls are case sensitive; try that.
Report Abuse
Darkmist101 is not online. Darkmist101
Joined: 30 Jul 2010
Total Posts: 6208
12 Jul 2012 07:14 AM
It was something like: String expected; got number.

tostring(Num1 .. Num2 .. Num3 .. Num4 .. Num5)

Report Abuse
Tonitoni is not online. Tonitoni
Joined: 14 Mar 2009
Total Posts: 6429
12 Jul 2012 07:15 AM
It worked! Thanks triston!
Report Abuse
AdvorsusDuo is not online. AdvorsusDuo
Joined: 17 May 2012
Total Posts: 5265
12 Jul 2012 07:15 AM
What triston said, or try adding a table.

-Nick
Report Abuse
triston220 is not online. triston220
Joined: 08 Mar 2010
Total Posts: 1861
12 Jul 2012 07:16 AM
No worries, I'm glad that I could be of assistance.
Report Abuse
Tonitoni is not online. Tonitoni
Joined: 14 Mar 2009
Total Posts: 6429
12 Jul 2012 07:16 AM
Although I don't see the difference between what I wrote and you wrote triston. It just worked for some wierd reason lol.
Report Abuse
triston220 is not online. triston220
Joined: 08 Mar 2010
Total Posts: 1861
12 Jul 2012 07:18 AM
Head.ClickDetector.MouseClick:connect(onClick)

See the lowercase o in onClick?

Your function name is OnClick, so that o needs to be capitalized. :)
Report Abuse
Tonitoni is not online. Tonitoni
Joined: 14 Mar 2009
Total Posts: 6429
12 Jul 2012 07:22 AM
Ah, okay. Thanks again.
Report Abuse
AdvorsusDuo is not online. AdvorsusDuo
Joined: 17 May 2012
Total Posts: 5265
12 Jul 2012 07:25 AM
What are you making? :o

-Nick
Report Abuse
Tonitoni is not online. Tonitoni
Joined: 14 Mar 2009
Total Posts: 6429
12 Jul 2012 07:27 AM
Just doing some tutorials :P
Report Abuse
triston220 is not online. triston220
Joined: 08 Mar 2010
Total Posts: 1861
12 Jul 2012 07:29 AM
Setting the random seed will also ensure that you can a different random each time the script is ran.

math.randomseed(tick())

You could put this at the top of the script or if you put it before each math.random call the numbers would be, well, more random.
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