UnBuild
|
  |
| Joined: 22 Mar 2013 |
| Total Posts: 3233 |
|
|
| 23 Apr 2013 06:35 PM |
How do I refer to the part my ray hit?
This is what I have, how would I make it print the position it hit the part at, and then remove the part
Tool = script.Parent Tool.Equipped:connect(function(Mouse) Mouse.Button1Down:connect(function() Laser = Ray.new(Tool.Handle.CFrame.p, (Mouse.Hit.p - Tool.Handle.CFrame.p).unit*300) end) end)
The wiki isn't being very helpful...
Wiki says
hit, position = game.Workspace:FindPartOnRay(ray, user)
And Im like...
Wut. I want to do it without the variable if I can, its easier that way |
|
|
| Report Abuse |
|
|
dekkonot
|
  |
| Joined: 22 Dec 2010 |
| Total Posts: 6685 |
|
|
| 23 Apr 2013 06:38 PM |
The wiki actually says that? xD Jeez I'm going to apply to be a writer this time around just so I can fix that sort of thing.
FindPartOnRay( Ray ray, Instance ignoreDescendentsInstance, Bool TerrainCellsAreCubes )
It's a member of workspace, and it returns:
BasePart object, Vector3 position with object being the part hit and position being where it hit it.
|
|
|
| Report Abuse |
|
|
UnBuild
|
  |
| Joined: 22 Mar 2013 |
| Total Posts: 3233 |
|
|
| 23 Apr 2013 06:40 PM |
... Can you say that in a more...Stupid way? Because I have no idea what you said past The wiki actually says that? xD Jeez I'm going to apply to be a writer this time around just so I can fix that sort of thing. |
|
|
| Report Abuse |
|
|
dekkonot
|
  |
| Joined: 22 Dec 2010 |
| Total Posts: 6685 |
|
|
| 23 Apr 2013 06:44 PM |
Okay, so for you to find what, and where, a ray hits you do this, for example
local hitObject, position = workspace:FindPartOnRay(Ray, nil)
where hitObject, obviously, is the object hit and position is the position 'hitObject' was hit. |
|
|
| Report Abuse |
|
|
UnBuild
|
  |
| Joined: 22 Mar 2013 |
| Total Posts: 3233 |
|
|
| 23 Apr 2013 06:45 PM |
18:45:25.796 - Unable to cast Dictionary to Ray 18:45:25.798 - Script "Workspace.Player1.LinkedPaintballGun.LocalScript", Line 6 18:45:25.800 - stack end 18:45:25.801 - Disconnected event because of exception
Tool = script.Parent Tool.Equipped:connect(function(Mouse) Mouse.Button1Down:connect(function() Laser = Ray.new(Tool.Handle.CFrame.p, (Mouse.Hit.p - Tool.Handle.CFrame.p).unit*300)
hitObject, position = workspace:FindPartOnRay(Ray, nil)
hitObject.BrickColor = BrickColor.new("Bright red") print(position)
end) end) |
|
|
| Report Abuse |
|
|
UnBuild
|
  |
| Joined: 22 Mar 2013 |
| Total Posts: 3233 |
|
| |
|