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 » Scripting Helpers
Home Search
 

Re: How to get the player from a part's lookVector?

Previous Thread :: Next Thread 
flatline115 is not online. flatline115
Joined: 29 Jul 2013
Total Posts: 7826
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
flatline115 is not online. flatline115
Joined: 29 Jul 2013
Total Posts: 7826
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
flatline115 is not online. flatline115
Joined: 29 Jul 2013
Total Posts: 7826
22 Aug 2013 02:26 PM
Output: Attempt to index local hit a 'nil' value
Report Abuse
sbk28 is not online. 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
flatline115 is not online. flatline115
Joined: 29 Jul 2013
Total Posts: 7826
22 Aug 2013 02:32 PM
That just returns no output.
Report Abuse
flatline115 is not online. flatline115
Joined: 29 Jul 2013
Total Posts: 7826
22 Aug 2013 05:59 PM
bump
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
22 Aug 2013 06:01 PM
ray is not a lookvector
Report Abuse
ZachBloxx is not online. ZachBloxx
Joined: 26 Jun 2013
Total Posts: 2833
22 Aug 2013 06:02 PM
local hit, position = Workspace:FindPartOnRay(ray, character)
Report Abuse
ZachBloxx is not online. 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
flatline115 is not online. flatline115
Joined: 29 Jul 2013
Total Posts: 7826
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
flatline115 is not online. flatline115
Joined: 29 Jul 2013
Total Posts: 7826
23 Aug 2013 01:11 AM
bump
Report Abuse
RaceToTheBottom is not online. RaceToTheBottom
Joined: 27 Jul 2013
Total Posts: 169
23 Aug 2013 01:18 AM
[ Content Deleted ]
Report Abuse
MHebes is not online. 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
flatline115 is not online. flatline115
Joined: 29 Jul 2013
Total Posts: 7826
23 Aug 2013 01:24 AM
A.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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