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
 

where do i put the function name...

Previous Thread :: Next Thread 
johnhugh is not online. johnhugh
Joined: 26 Mar 2009
Total Posts: 1971
05 Jul 2012 10:54 PM
script.Parent.Touched:connect((function)

end)
where do i put hit so i can do something like
p = hit.Parent:getPlayerFromCharacter(hit.Parent)
Report Abuse
SwiftE is not online. SwiftE
Joined: 04 Jul 2012
Total Posts: 2944
05 Jul 2012 10:56 PM
I guess it goes with the string????
Im not sure.
Report Abuse
johnhugh is not online. johnhugh
Joined: 26 Mar 2009
Total Posts: 1971
05 Jul 2012 10:56 PM
Nvm
also, correction script.Parent.Touched:connect(function(hit)
end)
Report Abuse
WhiteRain is not online. WhiteRain
Joined: 24 Apr 2010
Total Posts: 2723
05 Jul 2012 11:04 PM
If you format it like this then the Event fires an anonymous function which doesn't require a name.:

script.Parent.Touched:connect(function(hit)
--[[code]]--
end)

However if you wish to do it like this you do need to provide a name but I personally prefer the first method over this one:

function onTouched(hit)
--[[code]]--
end
script.Parent.Touched:connect(onTouched)

As you see in the second one the function is named onTouched and this really doesn't affect the code. You could have named it poop or even aethaen and it wouldn't matter as long as it was called in the connection line.
Report Abuse
WhiteRain is not online. WhiteRain
Joined: 24 Apr 2010
Total Posts: 2723
05 Jul 2012 11:07 PM
And for what you want, do this:

script.Parent.Touched:connect(function(hit)
char = hit.Parent
player = game.Players:GetPlayerFromCharacter(char)
end)
Report Abuse
WhiteRain is not online. WhiteRain
Joined: 24 Apr 2010
Total Posts: 2723
05 Jul 2012 11:25 PM
You're welcome.
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