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: Mouse.UnitRay only finding parts in the camera itself?

Previous Thread :: Next Thread 
DangCoolIsReal3 is not online. DangCoolIsReal3
Joined: 20 Dec 2014
Total Posts: 943
06 Aug 2016 05:54 PM
local Mouse = MyPlr:GetMouse()
local RP = workspace:FindPartOnRay(Mouse.UnitRay, nil, false, true)
if (RP ~= nil) then -- Everything it nil
print("0 Parent " .. RP.Name)
print("1 Parent " .. RP.Parent.Name)
local Find = Plrs:FindFirstChild(RP.Parent.Name) or Plrs:FindFirstChild(string.sub(RP.Parent.Name, string.len("ESPStuff ") + 1))
if (Find and Find ~= MyPlr) then
Aim = 500000
else
Aim = 1
end
else
Aim = 1
end


That code isn't printing anything, and I know it's working because if I put a part in the camera it'll print the name. How can create a ray from the mouse's position to a 3d position?


Report Abuse
thedailyblarg is not online. thedailyblarg
Joined: 26 Feb 2012
Total Posts: 5506
06 Aug 2016 05:56 PM
From a mouse to a 3d position?

(mouse.Hit.p-part.Position)

this is the direction * distance

Also equal to

(mouse.Hit.p-part.Position).Unit*(mouse.Hit.p-part.Position).Magnitude
Report Abuse
DangCoolIsReal3 is not online. DangCoolIsReal3
Joined: 20 Dec 2014
Total Posts: 943
06 Aug 2016 06:04 PM
@thedailyblarg, Strange same results, ray is only finding parts in the CurrentCamera still. It's not finding anything in the workspace?


Report Abuse
AggressiveCatch is not online. AggressiveCatch
Joined: 17 Jul 2011
Total Posts: 5840
06 Aug 2016 06:07 PM
why dont u make an actual ray?
Report Abuse
thedailyblarg is not online. thedailyblarg
Joined: 26 Feb 2012
Total Posts: 5506
06 Aug 2016 06:07 PM
I dont understand what you are trying to do..?
Report Abuse
DangCoolIsReal3 is not online. DangCoolIsReal3
Joined: 20 Dec 2014
Total Posts: 943
06 Aug 2016 06:35 PM
@thedailyblarg, I'm trying to create a ray from the players mouse position to 3d position the mouse is pointing at, which the UnitRay property does, but the problem is :FindPartOnRay doesn't detect anything unless it's in the player's camera. I need it so it detects objects in the workspace not just the camera. Really sorry if I'm not explaining myself good what I'm trying to do is rather difficult to explain.

@AggressiveCatch, no need to create one ROBLOX already does it for you. http://wiki.roblox.com/index.php?title=API:Class/Mouse/UnitRay


Report Abuse
AggressiveCatch is not online. AggressiveCatch
Joined: 17 Jul 2011
Total Posts: 5840
06 Aug 2016 06:48 PM
yeah but if it's not working the logical solution would be to create a ray of your own
Report Abuse
DangCoolIsReal3 is not online. DangCoolIsReal3
Joined: 20 Dec 2014
Total Posts: 943
06 Aug 2016 06:55 PM
@AggressiveCatch,
"@thedailyblarg, Strange same results, ray is only finding parts in the CurrentCamera still. It's not finding anything in the workspace?"

^^^^^^^^^^


Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
06 Aug 2016 07:02 PM
FindPartOnRay with a unit ray only detects things within a distance of one stud. You are aware of this, right?


Report Abuse
DangCoolIsReal3 is not online. DangCoolIsReal3
Joined: 20 Dec 2014
Total Posts: 943
06 Aug 2016 07:03 PM
@JarobOfOrbiter, holy crap I feel really dumb. Is there a way around this/?


Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
06 Aug 2016 07:05 PM
Make a new ray.

Ray.new(UnitRay.Origin, UnitRay.Direction * Length)


Length is 1 for unit rays, (That's what "unit" means) so multiplying it by a number between -5000 and 5000 will get you the distance you want. Negatives are obviously backwards, and FindPartOnRay is limited to 5000 studs. (Previously 1000)


Report Abuse
DangCoolIsReal3 is not online. DangCoolIsReal3
Joined: 20 Dec 2014
Total Posts: 943
06 Aug 2016 07:10 PM
@JarodOfOrbiter, thank you! That fixed it!


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