|
| 22 Aug 2013 02:22 PM |
How would I do it?
I know it'd be something like:
studs=10 --- function lookvec() human = script.Parent getlook = human.Head.CFrame.lookVector ray = Ray.new(human.Head.CFrame, getlook) local hit = game.Workspace:FindPartOnRay(ray) if hit.Parent:FindFirstChild("Humanoid") ~= nil then ehum = hit.Parent end return ehum end |
|
|
| Report Abuse |
|
|
|
| 22 Aug 2013 02:26 PM |
I ran that through but it gets stuck on this line:
local hit = game.Workspace:FindPartOnRay(ray)
|
|
|
| Report Abuse |
|
|
|
| 22 Aug 2013 02:26 PM |
| Output: Attempt to index local hit a 'nil' value |
|
|
| Report Abuse |
|
|
sbk28
|
  |
| Joined: 15 Nov 2008 |
| Total Posts: 2528 |
|
|
| 22 Aug 2013 02:27 PM |
if hit ~= nil and hit:FindFirstChild("Humanoid") ~= nil then
maybe? |
|
|
| Report Abuse |
|
|
|
| 22 Aug 2013 02:32 PM |
| That just returns no output. |
|
|
| Report Abuse |
|
|
| |
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
| |
|
ZachBloxx
|
  |
| Joined: 26 Jun 2013 |
| Total Posts: 2833 |
|
|
| 22 Aug 2013 06:02 PM |
| local hit, position = Workspace:FindPartOnRay(ray, character) |
|
|
| Report Abuse |
|
|
ZachBloxx
|
  |
| Joined: 26 Jun 2013 |
| Total Posts: 2833 |
|
|
| 22 Aug 2013 06:09 PM |
local studs=10
function GetCharacter() human = script.Parent head = human.Head local ray = Ray.new(head.CFrame.p, (Mouse.Hit.p - head.CFrame.p).unit*300) local hit, position = game.Workspace:FindPartOnRay(ray, head.Parent) if hit.Parent:FindFirstChild("Humanoid") and (position - head.Position).magnitude < studs then character = hit.Parent player = game.Players:GetPlayerFromCharacter(character) end return character,player end
-- you'll have to define Mouse |
|
|
| Report Abuse |
|
|
|
| 22 Aug 2013 07:47 PM |
| Zach you're misunderstanding what I want to do. I want to use the look vector of a part and try to find what is in front of the head. |
|
|
| Report Abuse |
|
|
| |
|
| |
|
MHebes
|
  |
| Joined: 04 Jan 2013 |
| Total Posts: 2278 |
|
|
| 23 Aug 2013 01:18 AM |
"I want to use the look vector of a part and try to find what is in front of the head." So wait, what do you want to do? Do you want to, a) Detect when a player is in front of a part, using that part's CFrame's lookVector, or b) Detect when a certain part is in front of the players head, using the head's lookVector? What you said above just didn't make sense.
~ Oh, I'm sorry, did I break your concentration? ~ |
|
|
| Report Abuse |
|
|
| |
|