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 » Scripters
Home Search
 

Re: How to look for a humanoid then make the humanoid take damag

Previous Thread :: Next Thread 
verysadmarcus is not online. verysadmarcus
Joined: 27 Jun 2009
Total Posts: 231
17 Aug 2016 07:12 AM
I ran out of space on the title, oh well. Anyway

Here is my script which is inside a tool with a Handle (local script)

local tool = script.Parent
local player = game.GetService("Players").LocalPlayer
local mouse = player.GetMouse()

function shoot()
if mouse.Target ~= nil then
if mouse.Target.Parent.Humanoid ~= nil then
mouse.Target.Parent.Humanoid:TakeDamange(35)
end
end
end

mouse.Button1Down:connect(shoot)


What is the problem here?

Is there an easier way to look for a Humanoid? Is that even the problem?


Report Abuse
JohnnyThunder2 is not online. JohnnyThunder2
Joined: 11 Apr 2009
Total Posts: 1043
17 Aug 2016 07:16 AM
:GetService not .GetService
:GetMouse not .GetMouse

if mouse.Target.Parent:findFirstChild("Humanoid") ~= nil

:TakeDamage not TakeDamange
Report Abuse
Purely2K is not online. Purely2K
Joined: 16 Feb 2015
Total Posts: 24
17 Aug 2016 07:18 AM
Hello,
From what I understand, you are looking to create a part to decrease Humanoid health.
I have a script that will do this exact thing:

script.Parent.Touched:connect(function(hit)
if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") then
hit.Parent.Humanoid.Health = 0
end
end)


If you would like to change the amount of damage the part takes, then change the value to whatever you want.
At the moment, this script will kill a player once they have touched the part.
However, you can set this to change the players health to 50 for example by putting "hit.Parent.Humanoid.Health = 50"

I hope this helps.
If you encounter any issues, please just message me and I am happy to help.

Thanks in advance,
Purely2k.
Report Abuse
booing is not online. booing
Joined: 04 May 2009
Total Posts: 6594
17 Aug 2016 07:41 AM
What is the point of "hit.Parent"?
Report Abuse
verysadmarcus is not online. verysadmarcus
Joined: 27 Jun 2009
Total Posts: 231
17 Aug 2016 07:51 AM
Thanks Johnny, that is a stupid mistake too! I understand completely now :)


Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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