|
| 08 Jan 2015 05:59 PM |
I want it to print the random numbers when I touch the brick that the script is in:
function onTouch(part) number = math.random(1,4) if number == 1 then print(1) end if number == 2 then print(2) end if number == 3 then print(3) end if number == 4 then print(4) end
Unfortunately something seems wrong. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 08 Jan 2015 06:01 PM |
You need to call the onTouch function when the part is actually touched. script.Parent.Touched:connect(onTouch);
Also you can do this:
function onTouch(part) local number = math.random(1, 4) print(number) end |
|
|
| Report Abuse |
|
|
|
| 08 Jan 2015 06:13 PM |
or you can do it the good way
script.Parent.Touched:connect(function(hit) end)
amomymoose functions are legion |
|
|
| Report Abuse |
|
|
|
| 08 Jan 2015 06:22 PM |
| Didn't work, by the way the brick is a Smooth Brick Model. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 08 Jan 2015 06:22 PM |
| Not really a "good way", just a different way that's slightly more efficient. |
|
|
| Report Abuse |
|
|
chimmihc
|
  |
| Joined: 01 Sep 2014 |
| Total Posts: 17143 |
|
|
| 08 Jan 2015 06:23 PM |
free model
there is no brick automatically named Smooth Brick Model. |
|
|
| Report Abuse |
|
|
|
| 09 Jan 2015 06:12 AM |
| I'll try the script using a Part. |
|
|
| Report Abuse |
|
|
|
| 09 Jan 2015 06:24 AM |
I don't understand, I tried all these methods and none worked on this Part. Here is the current script I need help with: script.Parent.Touched:connect(function(hit) end) if number == 1 then print(1) end if number == 2 then print(2) end if number == 3 then print(3) end if number == 4 then print(4) end
I want it to print random numbers on the top of my screen, but whenever I touch the part this script never turns on. |
|
|
| Report Abuse |
|
|
davisky2
|
  |
| Joined: 04 Mar 2012 |
| Total Posts: 4710 |
|
|
| 09 Jan 2015 07:06 AM |
script.Parent.Touched:connect(function(hit) number = math.random(1,4) print(number) end)
put this script into the part. |
|
|
| Report Abuse |
|
|
| |
|
Stefan631
|
  |
| Joined: 23 Dec 2010 |
| Total Posts: 1350 |
|
|
| 09 Jan 2015 02:29 PM |
| The print function prints onto the output.. Not your in-game screen. |
|
|
| Report Abuse |
|
|
instawin
|
  |
| Joined: 04 Jun 2013 |
| Total Posts: 8777 |
|
|
| 09 Jan 2015 02:32 PM |
if you didn't use an anonymous function, did you connect the function?
script.Parent.Touched:connect(onTouch) |
|
|
| Report Abuse |
|
|
|
| 09 Jan 2015 04:37 PM |
Even when I tried that, still no work.
Fine. Simce print only works on output (I guess) I want the randomizer on the game screen (headline). How do I do that? |
|
|
| Report Abuse |
|
|
| |
|
BowtieMod
|
  |
| Joined: 01 Apr 2013 |
| Total Posts: 804 |
|
| |
|
|
| 10 Jan 2015 12:01 PM |
| How do I script the math.random(1,4) with the gui? |
|
|
| Report Abuse |
|
|
| |
|
|
| 11 Jan 2015 08:19 AM |
script.Parent.Touched:connect(function() local number = math.random(1, 4) print(number) end)
have the output open
this makes your original script work |
|
|
| Report Abuse |
|
|
instawin
|
  |
| Joined: 04 Jun 2013 |
| Total Posts: 8777 |
|
|
| 11 Jan 2015 08:23 AM |
jaysus christ did you still not get this
ok, here's a script, study/edit
brick = script.Parent
deb = true
brick.Touched:connect(function(hit) hitHum = hit.Parent:FindFirstChild("Humanoid") if hitHum and deb then deb = false number = math.random(1,5) print(number) wait(2) deb = true end end)
prints a random number every time you touch it, with a debounce i am so generous l0l0l0l |
|
|
| Report Abuse |
|
|