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
 

Function help!

Previous Thread :: Next Thread 
WierdTony is not online. WierdTony
Joined: 27 Jul 2011
Total Posts: 1116
04 Feb 2012 04:09 PM
When I want Something to trigger, I make a function. I know how to do it, but the last line I don't.

function OnTouch(Bob)
Bob.Transparency = 1
end

________________________


I don't get that line.
Report Abuse
magnalite is not online. magnalite
Joined: 18 Oct 2009
Total Posts: 2467
04 Feb 2012 04:14 PM
That line there is called the "Connection Line" and basically that is the part of the script that define what calls the function so for that it would be -

script.Parent.Touched:connect(onTouch)

Although you can name the function anything you want EG"nom" it would just be this!

script.Parent.Touched:connect(nom)

and the part of the script you made would be this!

function nom(Bob)
Bob.Transparency = 1
end

Report Abuse
WierdTony is not online. WierdTony
Joined: 27 Jul 2011
Total Posts: 1116
04 Feb 2012 04:14 PM
Anyone?
Report Abuse
LevelNoobX is not online. LevelNoobX
Joined: 18 Sep 2011
Total Posts: 565
04 Feb 2012 04:15 PM
    script.Parent.Touched:connect(function(Bob)
    Bob.Transparency = 1
    end)

It's not easy being cheesy. I love Marilyn Mason,Sucicide Silence, and IWABO. Baseplate Maker Plugin here: http://www.roblox.com/Baseplate-maker-plugin-item?id=71012144
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
04 Feb 2012 04:16 PM
function OnTouch(Bob)
Bob.Transparency = 1
end
script.Parent.Touched:connect(OnTouch)


Touched is an event. Basically, an event waits for something specific to happen (for Touched, when one part collides with another part), then runs any functions associated (or linked) to the event. To link a function to an event, we use the connect method of the event.

Remember that anything the event returns (Touched returns the part that collided, Chatted returns the message, Selected returns the mouse, and so on) are passed on to the linked function as arguments.

If you're not quite sure what I mean, try reading this post:
http://www.roblox.com/Forum/ShowPost.aspx?PostID=62145553
Report Abuse
WierdTony is not online. WierdTony
Joined: 27 Jul 2011
Total Posts: 1116
04 Feb 2012 04:17 PM
I always have trouble with the connection line.
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
04 Feb 2012 04:20 PM
Forgot to mention ....

To use a connection, you simply call the connect method with a colon and supply your desired function (that you want to run) as the argument.


Here's a generic representation:

Object.Event:connect(MyFunction)


MyFunction can be ANY function. You can also supply what's called an Anonymous Function. These functions are just functions you do not store in a variable.


Object.Event:connect( function()
    -- content of the function here
end )

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