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: Touch Interest

Previous Thread :: Next Thread 
KodakKid3 is not online. KodakKid3
Joined: 25 Dec 2008
Total Posts: 2860
02 Sep 2013 08:01 PM
So, I wrote a little script here:

function onTouch(part)
script.Parent.Reflectance = 1
end

Which apparently won't work without this part on the end:

script.Parent.Touched:connect(onTouch)

What does that last line mean, and why do I need it? I thought the function onTouch worked fine on it's own.
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
02 Sep 2013 08:07 PM
'function onTouch()' is simply a function. It does not do anything until it is called or connected to an event that meets its conditions.

'script.Parent.Touched:connect(onTouch)' would fire 'function onTouch' when script.Parent touches something. Therefore, 'function onTouch' doesn't have to be named that. It could be:


function onPie(part)
script.Parent.Reflectance = 1
end

Which apparently won't work without this part on the end:

script.Parent.Touched:connect(onPie)

And it would work the same.
Report Abuse
KodakKid3 is not online. KodakKid3
Joined: 25 Dec 2008
Total Posts: 2860
02 Sep 2013 08:11 PM
So the Touched:Connect(onTouched) is what has the actual touch interest thing, and what calls the command?

And, it works find without one of those BasicObject Touchinterest things inside of it, why do some people use those?
Report Abuse
SpleenYanks is not online. SpleenYanks
Joined: 24 Aug 2008
Total Posts: 921
02 Sep 2013 08:13 PM
Just don't question it... Just do Whatever.Touched:connect(functionthing)...
Report Abuse
KodakKid3 is not online. KodakKid3
Joined: 25 Dec 2008
Total Posts: 2860
02 Sep 2013 08:14 PM
Spleen, I'm questioning it because I want to actually understand how it works.
Report Abuse
ToboboT is not online. ToboboT
Joined: 25 Jun 2011
Total Posts: 2385
02 Sep 2013 08:18 PM
Spleen you can't do something if you don't know what you are doing and Koda, your answer:

I always hated when scripters used these words that I don't know about and it would mess me up, so here's how I thought of it. The correct name for those lines are connectors. Because they connect to functions. But that confused me so I thought of scripts as guns.

The gun power and barrel is the functions and the code and the trigger is the connection line. So think on part.Touched:connect() as whenever that part is touched you pull a trigger which lights the gun powder named your function. Understand?

Thats the easiest way i could think of explaining it
Report Abuse
KodakKid3 is not online. KodakKid3
Joined: 25 Dec 2008
Total Posts: 2860
02 Sep 2013 08:20 PM
Yeah, I think I get it. Thanks guys.
Report Abuse
ToboboT is not online. ToboboT
Joined: 25 Jun 2011
Total Posts: 2385
02 Sep 2013 08:22 PM
Anytime, and if you still don't understand PM I'll be glad to help! :)
Report Abuse
SpleenYanks is not online. SpleenYanks
Joined: 24 Aug 2008
Total Posts: 921
02 Sep 2013 08:28 PM
Well geez... that's mean >->
Report Abuse
ToboboT is not online. ToboboT
Joined: 25 Jun 2011
Total Posts: 2385
02 Sep 2013 08:29 PM
Nobody said anything mean.
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