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: Parent, Desendant/Child

Previous Thread :: Next Thread 
wow75 is not online. wow75
Joined: 16 Jan 2009
Total Posts: 951
05 Jan 2012 09:41 AM
Am i allowed to do this?

if hit.Parent.Parent.Desendant == Blah

Or

if hit.Parent.Parent.Child == Blah
Report Abuse
Fl0x is not online. Fl0x
Joined: 06 Aug 2010
Total Posts: 5169
05 Jan 2012 09:51 AM
if Blah:IsDescendantOf(hit.Parent.Parent) then
Report Abuse
wow75 is not online. wow75
Joined: 16 Jan 2009
Total Posts: 951
05 Jan 2012 09:52 AM
Cool, i can work with that.
Report Abuse
wow75 is not online. wow75
Joined: 16 Jan 2009
Total Posts: 951
05 Jan 2012 10:10 AM
I have a new question, in a weapon, how would you say the wielder of the weapon. For example:
function OnTouched(hit)
WielderOfWeapon.WalkSpeed = 30
end
Report Abuse
grimm343 is not online. grimm343
Joined: 18 Sep 2008
Total Posts: 2796
05 Jan 2012 10:15 AM
If it's a tool, and the script is a Child of the Tool, then the Character is..
script.Parent.Parent
When equipped, anyway..

The Character of a HopperBin, at all times after being in the Backpack, is either
game.Players.LocalPlayer
or
script.Parent.Parent.Parent.Character

The reason the first one could work, is because HopperBins use LocalScripts, and the HopperBin is a Descendant of the Player.
Report Abuse
wow75 is not online. wow75
Joined: 16 Jan 2009
Total Posts: 951
05 Jan 2012 10:17 AM
I see now, thank you! Well, back to weapon creating! :D
Report Abuse
wow75 is not online. wow75
Joined: 16 Jan 2009
Total Posts: 951
05 Jan 2012 10:20 AM
Ok, one final question: When i put: "function OnTouched(hit)" What exactly does the hit do? And could i make it something else?
Report Abuse
Ravenshield is not online. Ravenshield
Joined: 21 Nov 2007
Total Posts: 4143
05 Jan 2012 10:30 AM
In a script.Parent.Touched:connect(function(hit) end) (or function OnTouched(hit) + connectionline, in other words), the 'hit' (can be anything. Call it "block", "blaergg", "aeriobaeuhrubihaeir" if you wish) defines the brick or object that touched your object.

Therefore, if we use

script.Parent.Touched:connect(function(hit)
print(hit.Name)
end)

it would print 'Part6', if Part6 was the name of the object that touched it.

Not the best explanation, though.
Report Abuse
wow75 is not online. wow75
Joined: 16 Jan 2009
Total Posts: 951
05 Jan 2012 10:35 AM
That's a perfect defenition! :D It was one of the only things i didnt truly understand on the wiki. So thank you! =D
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