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
|
  |
| Joined: 06 Aug 2010 |
| Total Posts: 5169 |
|
|
| 05 Jan 2012 09:51 AM |
| if Blah:IsDescendantOf(hit.Parent.Parent) then |
|
|
| Report Abuse |
|
|
wow75
|
  |
| Joined: 16 Jan 2009 |
| Total Posts: 951 |
|
|
| 05 Jan 2012 09:52 AM |
| Cool, i can work with that. |
|
|
| Report Abuse |
|
|
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
|
  |
| 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
|
  |
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|