vvoods
|
  |
| Joined: 02 Nov 2013 |
| Total Posts: 743 |
|
|
| 19 Jun 2015 12:03 AM |
How do I get the humanoid when the bullet hit the person?
Code:
local tool = script.Parent local user
tool.Equipped:connect(function(mouse) user = tool.Parent mouse.Button1Down:connect(function() local bullet = Instance.new("Part", game.Workspace) game.Debris:AddItem(bullet, 3) bullet.Shape = "Ball" bullet.Size = Vector3.new(1, 1, 1) bullet.BrickColor = BrickColor.new("Really black") bullet.CanCollide = false bullet.CFrame = tool.Handle.CFrame bullet.CFrame = CFrame.new(bullet.Position, mouse.Hit.p) local sm = Instance.new("SpecialMesh", bullet) sm.MeshType = "Sphere" sm.Scale = Vector3.new(.2, .2, .2) local v = Instance.new("BodyVelocity", bullet) v.velocity = bullet.CFrame.lookVector *90 v.maxForce = Vector3.new(math.huge, math.huge, math.huge) end) end)
=volty= |
|
|
| Report Abuse |
|
|
vvoods
|
  |
| Joined: 02 Nov 2013 |
| Total Posts: 743 |
|
|
| 19 Jun 2015 12:07 AM |
Isn't it like bullet.Hit or something
=volty= |
|
|
| Report Abuse |
|
|
DrSaint
|
  |
| Joined: 14 Oct 2009 |
| Total Posts: 18429 |
|
|
| 19 Jun 2015 12:07 AM |
| Maybe a on touched function to detect if the bullet touched a humanoid or not? |
|
|
| Report Abuse |
|
|
robocu3
|
  |
| Joined: 13 Mar 2009 |
| Total Posts: 6485 |
|
|
| 19 Jun 2015 12:10 AM |
local function GetHumanoid(obj) local humanoid local parent = obj.Parent repeat humanoid = parent:FindFirstChild("Humanoid") parent = parent.Parent until humanoid or not parent return humanoid end
I think that'll work, unless I'm making some really stupid logic flaw.
-=Robo=- |
|
|
| Report Abuse |
|
|
vvoods
|
  |
| Joined: 02 Nov 2013 |
| Total Posts: 743 |
|
|
| 19 Jun 2015 12:22 AM |
I don't know exactly how to do the ontouched with the bullet thing, i tried but no work
local tool = script.Parent local user
tool.Equipped:connect(function(mouse) user = tool.Parent mouse.Button1Down:connect(function() local bullet = Instance.new("Part", game.Workspace) game.Debris:AddItem(bullet, 3) bullet.Shape = "Ball" bullet.Size = Vector3.new(1, 1, 1) bullet.BrickColor = BrickColor.new("Really black") bullet.CanCollide = false bullet.CFrame = tool.Handle.CFrame bullet.CFrame = CFrame.new(bullet.Position, mouse.Hit.p) local sm = Instance.new("SpecialMesh", bullet) sm.MeshType = "Sphere" sm.Scale = Vector3.new(.2, .2, .2) local v = Instance.new("BodyVelocity", bullet) v.velocity = bullet.CFrame.lookVector *90 v.maxForce = Vector3.new(math.huge, math.huge, math.huge) local function human(hit) local human = hit.Parent:WaitForChild("Humanoid") if human ~= nil then human:TakeDamage(10) end end end) end)
=volty= |
|
|
| Report Abuse |
|
|
vvoods
|
  |
| Joined: 02 Nov 2013 |
| Total Posts: 743 |
|
|
| 19 Jun 2015 12:23 AM |
forgot connection
local tool = script.Parent local user
tool.Equipped:connect(function(mouse) user = tool.Parent mouse.Button1Down:connect(function() local bullet = Instance.new("Part", game.Workspace) game.Debris:AddItem(bullet, 3) bullet.Shape = "Ball" bullet.Size = Vector3.new(1, 1, 1) bullet.BrickColor = BrickColor.new("Really black") bullet.CanCollide = false bullet.CFrame = tool.Handle.CFrame bullet.CFrame = CFrame.new(bullet.Position, mouse.Hit.p) local sm = Instance.new("SpecialMesh", bullet) sm.MeshType = "Sphere" sm.Scale = Vector3.new(.2, .2, .2) local v = Instance.new("BodyVelocity", bullet) v.velocity = bullet.CFrame.lookVector *90 v.maxForce = Vector3.new(math.huge, math.huge, math.huge) local function human(hit) local human = hit.Parent:WaitForChild("Humanoid") if human ~= nil then human:TakeDamage(10) bullet.Touched:connect(human) end end end) end)
=volty= |
|
|
| Report Abuse |
|
|
robocu3
|
  |
| Joined: 13 Mar 2009 |
| Total Posts: 6485 |
|
|
| 19 Jun 2015 12:25 AM |
Touched is an event. Just connect it to the function and you're good to go.
-=Robo=- |
|
|
| Report Abuse |
|
|
vvoods
|
  |
| Joined: 02 Nov 2013 |
| Total Posts: 743 |
|
| |
|
DrSaint
|
  |
| Joined: 14 Oct 2009 |
| Total Posts: 18429 |
|
|
| 19 Jun 2015 12:26 AM |
@Robo
Was I close to right? Lol |
|
|
| Report Abuse |
|
|
vvoods
|
  |
| Joined: 02 Nov 2013 |
| Total Posts: 743 |
|
|
| 19 Jun 2015 12:27 AM |
i put the connection in the function silly me C:
=volty= |
|
|
| Report Abuse |
|
|
robocu3
|
  |
| Joined: 13 Mar 2009 |
| Total Posts: 6485 |
|
|
| 19 Jun 2015 12:28 AM |
Kind of. Humanoids are not rendered instances, therefor collisions do not apply to them. Though if you were to detect whether or not you hit an instance that had a humanoid somewhere in it's ancestry, you could deal damage that way using touched events.
-=Robo=- |
|
|
| Report Abuse |
|
|
DrSaint
|
  |
| Joined: 14 Oct 2009 |
| Total Posts: 18429 |
|
|
| 19 Jun 2015 12:29 AM |
@Robo
Haha thanks. I'm still getting my footing in scripting. |
|
|
| Report Abuse |
|
|