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: Ray casting

Previous Thread :: Next Thread 
UnBuild is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. UnBuild
Joined: 22 Mar 2013
Total Posts: 3233
23 Apr 2013 06:49 PM
Nvm, Thanks! :D
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