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: How do I make this script work?

Previous Thread :: Next Thread 
racinglover is not online. racinglover
Joined: 13 Feb 2010
Total Posts: 690
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 is not online. 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
ChiefDelta is not online. ChiefDelta
Joined: 05 Nov 2010
Total Posts: 13071
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
racinglover is not online. racinglover
Joined: 13 Feb 2010
Total Posts: 690
08 Jan 2015 06:22 PM
Didn't work, by the way the brick is a Smooth Brick Model.
Report Abuse
cntkillme is not online. 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 is not online. 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
racinglover is not online. racinglover
Joined: 13 Feb 2010
Total Posts: 690
09 Jan 2015 06:12 AM
I'll try the script using a Part.
Report Abuse
racinglover is not online. racinglover
Joined: 13 Feb 2010
Total Posts: 690
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 is not online. 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
racinglover is not online. racinglover
Joined: 13 Feb 2010
Total Posts: 690
09 Jan 2015 02:19 PM
Still doesn't work! wow
Report Abuse
Stefan631 is not online. 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 is not online. 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
racinglover is not online. racinglover
Joined: 13 Feb 2010
Total Posts: 690
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
racinglover is not online. racinglover
Joined: 13 Feb 2010
Total Posts: 690
10 Jan 2015 11:36 AM
Bump
Report Abuse
BowtieMod is not online. BowtieMod
Joined: 01 Apr 2013
Total Posts: 804
10 Jan 2015 11:42 AM
Use a GUI.

Report Abuse
racinglover is not online. racinglover
Joined: 13 Feb 2010
Total Posts: 690
10 Jan 2015 12:01 PM
How do I script the math.random(1,4) with the gui?
Report Abuse
racinglover is not online. racinglover
Joined: 13 Feb 2010
Total Posts: 690
11 Jan 2015 08:12 AM
Bump
Report Abuse
DoAndDoOver is not online. DoAndDoOver
Joined: 06 Sep 2014
Total Posts: 628
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 is not online. 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
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