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: Whats wrong with this?

Previous Thread :: Next Thread 
Bylocks is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. Bylocks
Joined: 27 Mar 2012
Total Posts: 773
10 May 2017 07:21 PM
i put spaces cause roblox filter
Report Abuse
Canmanage is not online. 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 is not online. Bylocks
Joined: 27 Mar 2012
Total Posts: 773
10 May 2017 07:29 PM
so what should i do?
Report Abuse
Bylocks is not online. Bylocks
Joined: 27 Mar 2012
Total Posts: 773
10 May 2017 07:35 PM
what value should newray be
Report Abuse
Canmanage is not online. 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 is not online. 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 is not online. 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
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