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
We use cookies to offer you a better experience. By using Roblox.com, you are agreeing to our Privacy and Cookie Policy.
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Only damage monsters?

Previous Thread :: Next Thread 
axelvts is not online. 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 is not online. DanDev
Joined: 23 May 2014
Total Posts: 34
27 Sep 2014 10:08 AM
created another object called monster inside it.
Report Abuse
Kodran is not online. Kodran
Joined: 15 Aug 2013
Total Posts: 5330
27 Sep 2014 10:10 AM
if hit.Parent.Name == "Monster" then
Report Abuse
SenseiWarrior is online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
27 Sep 2014 10:10 AM
if not game.Players:FindFirstChild(hit.Parent.Name) then
Report Abuse
axelvts is not online. 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 is not online. axelvts
Joined: 27 Apr 2008
Total Posts: 3029
27 Sep 2014 10:14 AM
Oops, mkay guys, I'll try them. : )
Report Abuse
axelvts is not online. 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 is not online. 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
ViciousFox is not online. ViciousFox
Joined: 22 Oct 2009
Total Posts: 1596
27 Sep 2014 10:26 AM
rename the monsters humanoid to "Monster_h"

local humanoid = hit.Parent:findFirstChild("Monster_h")
Report Abuse
axelvts is not online. 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
SenseiWarrior is online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
27 Sep 2014 10:31 AM
Did you try mine
Report Abuse
OzzyFin is not online. 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 is not online. 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 is not online. axelvts
Joined: 27 Apr 2008
Total Posts: 3029
27 Sep 2014 10:49 AM
: /

Need this for the GCC contest.....
Report Abuse
axelvts is not online. 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 is not online. 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 is not online. axelvts
Joined: 27 Apr 2008
Total Posts: 3029
27 Sep 2014 02:38 PM
It was hit.Parent. Many thanks to you!
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