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: Humanoid help

Previous Thread :: Next Thread 
vvoods is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. vvoods
Joined: 02 Nov 2013
Total Posts: 743
19 Jun 2015 12:25 AM
O, nvm i fixed it!



=volty=
Report Abuse
DrSaint is not online. DrSaint
Joined: 14 Oct 2009
Total Posts: 18429
19 Jun 2015 12:26 AM
@Robo

Was I close to right? Lol
Report Abuse
vvoods is not online. 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 is not online. 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 is not online. 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
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