opplo
|
  |
| Joined: 09 Dec 2008 |
| Total Posts: 5320 |
|
|
| 15 Aug 2013 01:18 PM |
Basically, I'm trying to find out if the ray has hit a Player. The output is telling me "Parent is not a valid member"
ray = Ray.new(veh.Gun.Shooter.Position, (veh.Gun.Shooter.CFrame.lookVector).unit * 300) part,hit = Workspace:FindPartOnRay(ray)
humanoid = hit.Parent:findFirstChild("Humanoid") if humanoid then humanoid:TakeDamage(30) end |
|
|
| Report Abuse |
|
|
opplo
|
  |
| Joined: 09 Dec 2008 |
| Total Posts: 5320 |
|
|
| 15 Aug 2013 01:19 PM |
| The output is responding to this line btw. "humanoid = hit.Parent:findFirstChild("Humanoid")" |
|
|
| Report Abuse |
|
|
|
| 15 Aug 2013 01:34 PM |
ray = Ray.new(veh.Gun.Shooter.Position, (veh.Gun.Shooter.CFrame.lookVector).unit * 300) part,hit = Workspace:FindPartOnRay(ray)
if hit.Parent.Humanoid then hit.Parent.Humanoid:TakeDamage(30) end
try that, not sure if it'll work though |
|
|
| Report Abuse |
|
|
opplo
|
  |
| Joined: 09 Dec 2008 |
| Total Posts: 5320 |
|
|
| 15 Aug 2013 01:36 PM |
| That won't change anything. |
|
|
| Report Abuse |
|
|
zars15
|
  |
| Joined: 10 Nov 2008 |
| Total Posts: 9999 |
|
|
| 15 Aug 2013 01:44 PM |
ray = Ray.new(veh.Gun.Shooter.Position, (veh.Gun.Shooter.CFrame.lookVector).unit * 300) part,hit = Workspace:FindPartOnRay(ray)
if part and part.Parent:findFirstChild("Humanoid") then local humanoid = hit.Parent:findFirstChild("Humanoid") humanoid:TakeDamage(30) end |
|
|
| Report Abuse |
|
|
opplo
|
  |
| Joined: 09 Dec 2008 |
| Total Posts: 5320 |
|
|
| 15 Aug 2013 01:49 PM |
| That's got it working so that it works. But now when it hits a person it returns that error and the player doesn't take damage. |
|
|
| Report Abuse |
|
|
opplo
|
  |
| Joined: 09 Dec 2008 |
| Total Posts: 5320 |
|
|
| 15 Aug 2013 01:59 PM |
Got it working, thanks.
local humanoid = part and part.Parent and part.Parent:findFirstChild("Humanoid") if humanoid then humanoid:TakeDamage(30) |
|
|
| Report Abuse |
|
|