axelvts
|
  |
| Joined: 27 Apr 2008 |
| Total Posts: 3029 |
|
|
| 27 Sep 2014 10:07 AM |
Okay, so I'm making a weapon that only damages monsters..... I could just rename Humanoid to Monsteroid or something like that, but that would mess with the monster's Path finding... Is there any way I could make this script damage monsters based on name?
local humanoid = hit.Parent:findFirstChild("Humanoid")
All the monster's names are " Monster " however, the names are invisible.
So anyways- Yeah..... I don't want players to get damaged. |
|
|
| Report Abuse |
|
|
DanDev
|
  |
| Joined: 23 May 2014 |
| Total Posts: 34 |
|
|
| 27 Sep 2014 10:08 AM |
| created another object called monster inside it. |
|
|
| Report Abuse |
|
|
Kodran
|
  |
| Joined: 15 Aug 2013 |
| Total Posts: 5330 |
|
|
| 27 Sep 2014 10:10 AM |
| if hit.Parent.Name == "Monster" then |
|
|
| Report Abuse |
|
|
|
| 27 Sep 2014 10:10 AM |
| if not game.Players:FindFirstChild(hit.Parent.Name) then |
|
|
| Report Abuse |
|
|
axelvts
|
  |
| Joined: 27 Apr 2008 |
| Total Posts: 3029 |
|
|
| 27 Sep 2014 10:12 AM |
| Alright, but will this damage both Humanoid and Monsteroid if I have it set to damage Monsteroid? Because- I don't want the AI to continue running after monster dies and I don't want it to have two healths, ya know? Like continuing even after one Humanoid (Monsteroid) dies. |
|
|
| Report Abuse |
|
|
axelvts
|
  |
| Joined: 27 Apr 2008 |
| Total Posts: 3029 |
|
|
| 27 Sep 2014 10:14 AM |
| Oops, mkay guys, I'll try them. : ) |
|
|
| Report Abuse |
|
|
axelvts
|
  |
| Joined: 27 Apr 2008 |
| Total Posts: 3029 |
|
|
| 27 Sep 2014 10:20 AM |
Erm..... They don't seem to be working.....
Would I do
local humanoid = hit.Parent:findFirstChild("Humanoid")
after the scripts or would I replace the line with it? |
|
|
| Report Abuse |
|
|
axelvts
|
  |
| Joined: 27 Apr 2008 |
| Total Posts: 3029 |
|
|
| 27 Sep 2014 10:23 AM |
| Yeah, those lines just break it..... Not damaging even the monster..... |
|
|
| Report Abuse |
|
|
|
| 27 Sep 2014 10:26 AM |
rename the monsters humanoid to "Monster_h"
local humanoid = hit.Parent:findFirstChild("Monster_h") |
|
|
| Report Abuse |
|
|
axelvts
|
  |
| Joined: 27 Apr 2008 |
| Total Posts: 3029 |
|
|
| 27 Sep 2014 10:28 AM |
Wait, what? I said above that changing the Humanoid's name will break the PathFind..... |
|
|
| Report Abuse |
|
|
| |
|
OzzyFin
|
  |
| Joined: 07 Jun 2011 |
| Total Posts: 3600 |
|
|
| 27 Sep 2014 10:32 AM |
Check if hit.Parent doesn't have a player at game.Players using :GetPlayerFromCharacter, if true then do damage.
There was one guy using :FindFirstChild at Players what should work for this aswell.. |
|
|
| Report Abuse |
|
|
axelvts
|
  |
| Joined: 27 Apr 2008 |
| Total Posts: 3029 |
|
|
| 27 Sep 2014 10:36 AM |
Well, I tried them..... Here, I'll paste the entire chunk of code from that script:
function blow(hit) local humanoid = hit.Parent:findFirstChild("Humanoid") local vCharacter = Tool.Parent local vPlayer = game.Players:playerFromCharacter(vCharacter) local hum = vCharacter:findFirstChild("Humanoid") -- non-nil if tool held by a character if humanoid~=nil and humanoid ~= hum and hum ~= nil then tagHumanoid(humanoid, vPlayer) humanoid:TakeDamage(damage) usageCount = usageCount - 1 if usageCount <= 0 then Tool:Destroy() end end end
(Comes from the Slappy Salmon BTW) |
|
|
| Report Abuse |
|
|
axelvts
|
  |
| Joined: 27 Apr 2008 |
| Total Posts: 3029 |
|
|
| 27 Sep 2014 10:49 AM |
: /
Need this for the GCC contest..... |
|
|
| Report Abuse |
|
|
axelvts
|
  |
| Joined: 27 Apr 2008 |
| Total Posts: 3029 |
|
|
| 27 Sep 2014 10:56 AM |
Actually, after I re read it, it might be the
local vPlayer = game.Players:playerFromCharacter(vCharacter)
parts that need changing.......... |
|
|
| Report Abuse |
|
|
OzzyFin
|
  |
| Joined: 07 Jun 2011 |
| Total Posts: 3600 |
|
|
| 27 Sep 2014 11:01 AM |
function blow(hit) local humanoid = hit.Parent:findFirstChild("Humanoid") if humanoid and game.Players:GetPlayerFromCharacter(hit.Parent) == nil then local vPlayer = game.Players:GetPlayerFromCharacter(tool.Parent) -- I don't know are you supposed to get the player who it hits here. If so, then just change to (hit.Parent) tagHumanoid(humanoid, vPlayer) humanoid:TakeDamage(damage) usageCount = usageCount - 1 if usageCount <= 0 then Tool:Destroy() end end end |
|
|
| Report Abuse |
|
|
axelvts
|
  |
| Joined: 27 Apr 2008 |
| Total Posts: 3029 |
|
|
| 27 Sep 2014 02:38 PM |
| It was hit.Parent. Many thanks to you! |
|
|
| Report Abuse |
|
|