Bylocks
|
  |
| Joined: 27 Mar 2012 |
| Total Posts: 773 |
|
|
| 10 May 2017 06:50 PM |
local part,position,normal,material = workspace:FindPartOnRay(newRay) if part.Name == "Base1" then -- if the part is the baseplate and not the player's base then print('fail') end
i created the ray thats just getting #'ed by roblox but the error is it says part is a nil value. |
|
|
| Report Abuse |
|
|
EW5A
|
  |
| Joined: 10 Nov 2015 |
| Total Posts: 722 |
|
|
| 10 May 2017 06:59 PM |
"the part is the baseplate and not the player's base"
doesn't work |
|
|
| Report Abuse |
|
|
Canmanage
|
  |
| Joined: 03 Dec 2007 |
| Total Posts: 59 |
|
|
| 10 May 2017 07:03 PM |
The ray is not hitting a part, so the 'part' that it returns is nil.
Add a nil check like this:
if part then if part.Name == "Base1" then print('fail') end else print("Ray did not hit anything") end |
|
|
| Report Abuse |
|
|
Bylocks
|
  |
| Joined: 27 Mar 2012 |
| Total Posts: 773 |
|
|
| 10 May 2017 07:10 PM |
| its saying its not hitting anything, even when i hover over the baseplate with the model |
|
|
| Report Abuse |
|
|
Canmanage
|
  |
| Joined: 03 Dec 2007 |
| Total Posts: 59 |
|
|
| 10 May 2017 07:14 PM |
| Double check to make sure you're creating the ray properly. It's possible that you've got it casting in the wrong direction or something. |
|
|
| Report Abuse |
|
|
Bylocks
|
  |
| Joined: 27 Mar 2012 |
| Total Posts: 773 |
|
|
| 10 May 2017 07:21 PM |
local okay = r a y . new (ghost.Main.Position,Vector3.new(0,-10,0)) local part,position,normal,material = workspace : FindPartOnRay( newRay ) if part then if part.Name == "Baseplate" then print('fail') end else print("Ray did not hit anything") |
|
|
| Report Abuse |
|
|
Bylocks
|
  |
| Joined: 27 Mar 2012 |
| Total Posts: 773 |
|
|
| 10 May 2017 07:21 PM |
| i put spaces cause roblox filter |
|
|
| Report Abuse |
|
|
Canmanage
|
  |
| Joined: 03 Dec 2007 |
| Total Posts: 59 |
|
|
| 10 May 2017 07:24 PM |
| 'newRay' is never given a value from what you've posted. The ray that you're creating is being stored in 'okay'. |
|
|
| Report Abuse |
|
|
Bylocks
|
  |
| Joined: 27 Mar 2012 |
| Total Posts: 773 |
|
| |
|
Bylocks
|
  |
| Joined: 27 Mar 2012 |
| Total Posts: 773 |
|
|
| 10 May 2017 07:35 PM |
| what value should newray be |
|
|
| Report Abuse |
|
|
Canmanage
|
  |
| Joined: 03 Dec 2007 |
| Total Posts: 59 |
|
|
| 10 May 2017 07:37 PM |
Well you're creating a ray and storing it in 'okay'. After that you're never using 'okay' again.
Instead, you're passing the new (empty) variable 'newRay' to :FindPartOnRay() so it's no surprise that you're getting nil values returned.
Try storing the ray in to 'newRay' instead so that the ray actually gets passed to :FindPartOnRay()
|
|
|
| Report Abuse |
|
|
Bylocks
|
  |
| Joined: 27 Mar 2012 |
| Total Posts: 773 |
|
|
| 10 May 2017 07:40 PM |
| same stuff when i changed okay to newray |
|
|
| Report Abuse |
|
|
Canmanage
|
  |
| Joined: 03 Dec 2007 |
| Total Posts: 59 |
|
|
| 10 May 2017 07:50 PM |
Then it seems like your ray isn't hitting anything after all.
Take a look at the wiki to see if you're constructing the ray the way you want to: wiki.roblox.com/index.php?title=Ray |
|
|
| Report Abuse |
|
|