|
| 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 |
|
|
|
| 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
|
  |
| 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
|
  |
| Joined: 04 May 2009 |
| Total Posts: 6594 |
|
|
| 17 Aug 2016 07:41 AM |
| What is the point of "hit.Parent"? |
|
|
| Report Abuse |
|
|
|
| 17 Aug 2016 07:51 AM |
Thanks Johnny, that is a stupid mistake too! I understand completely now :)
|
|
|
| Report Abuse |
|
|