|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 06 Aug 2016 06:07 PM |
| why dont u make an actual ray? |
|
|
| Report Abuse |
|
|
|
| 06 Aug 2016 06:07 PM |
| I dont understand what you are trying to do..? |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 06 Aug 2016 07:03 PM |
@JarobOfOrbiter, holy crap I feel really dumb. Is there a way around this/?
|
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 06 Aug 2016 07:10 PM |
@JarodOfOrbiter, thank you! That fixed it!
|
|
|
| Report Abuse |
|
|