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: Checking if hit

Previous Thread :: Next Thread 
Akbarr is not online. Akbarr
Joined: 02 Nov 2012
Total Posts: 5547
19 May 2013 11:35 AM
How can I check if part or position are nil without it erroring?
It errors WHEN it gets the values, that means you can't do "if hit then" or "if game.Workspace:FindPartOnRay(lalal,lalal)"

I need to figure out how to stop the ray at a certain height or just have the function forfeit before it reaches nil.

local hit, position = game.Workspace:FindPartOnRay(part,position)
Report Abuse
Akbarr is not online. Akbarr
Joined: 02 Nov 2012
Total Posts: 5547
19 May 2013 11:41 AM
Bump
~Sharpshooter26/firemonkSEE
Report Abuse
MrNicNac is not online. MrNicNac
Joined: 29 Aug 2008
Total Posts: 26567
19 May 2013 11:42 AM
Your error is in the actual function call. The second argument is not a position.
Report Abuse
Akbarr is not online. Akbarr
Joined: 02 Nov 2012
Total Posts: 5547
19 May 2013 11:46 AM
By that do you mean that the script is attempting define something nil or are you saying I defined the incorrectly in the script?
~Sharpshooter26/firemonkSEE
Report Abuse
MrNicNac is not online. MrNicNac
Joined: 29 Aug 2008
Total Posts: 26567
19 May 2013 11:49 AM
"local hit, position = game.Workspace:FindPartOnRay(part,position)"

Notice the two things you're giving that function (part, position). You don't give it those things. You have to give it a ray. For example:

local ray = Ray.new(position, direction)
local hit, position = game.Workspace:FindPartOnRay(ray)
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