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: Raycast

Previous Thread :: Next Thread 
Fedorakid is not online. Fedorakid
Joined: 17 Jul 2010
Total Posts: 7079
09 Nov 2012 12:42 PM
What does findpartonray do and if someone can explain this script:


tool = script.Parent
tool.Equipped:connect(function(mouse)
user = tool.Parent
mouse.Button1Down:connect(function()

ray = Ray.new(tool.Handle.CFrame.p, (mouse.Hit.p - tool.Handle.CFrame.p).unit*300)

hit, position = game.Workspace:FindPartOnRay(ray, user)
humanoid = hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid")
if humanoid then
humanoid:TakeDamage(30)
end

distance = (position - tool.Handle.CFrame.p).magnitude

rayPart = Instance.new("Part", user)
rayPart.Name = "RayPart"
rayPart.BrickColor = BrickColor.new("Bright red")
rayPart.Transparency = 0.5
rayPart.Anchored = true
rayPart.CanCollide = false
rayPart.TopSurface = Enum.SurfaceType.Smooth
rayPart.BottomSurface = Enum.SurfaceType.Smooth
rayPart.formFactor = Enum.FormFactor.Custom
rayPart.Size = Vector3.new(0.2, 0.2, distance)
rayPart.CFrame = CFrame.new(position, tool.Handle.CFrame.p) * CFrame.new(0, 0, -distance/2)

game.Debris:AddItem(rayPart, 0.1)
end)
end)
Report Abuse
FreeToTake is not online. FreeToTake
Joined: 21 Apr 2010
Total Posts: 1827
09 Nov 2012 01:20 PM
ray is a raycast between the handle of your tool and the hit position of your mouse.

:findPartOnRay()
returns the first part that gets hit by the ray.
Report Abuse
Fedorakid is not online. Fedorakid
Joined: 17 Jul 2010
Total Posts: 7079
09 Nov 2012 02:06 PM
I dont get the findpartonray() line explain it pl0x?
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
09 Nov 2012 02:08 PM
Or you could be a programmer and look at the documentation on the wiki...
Report Abuse
Fedorakid is not online. Fedorakid
Joined: 17 Jul 2010
Total Posts: 7079
09 Nov 2012 02:09 PM
Or u could stop comming with stuff that doesent help.And please no complains i said that.
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
09 Nov 2012 02:12 PM
I'm pretty sure I just told you where you could get your information.
You're welcome.
Report Abuse
Fedorakid is not online. Fedorakid
Joined: 17 Jul 2010
Total Posts: 7079
09 Nov 2012 02:49 PM
As i said, no spam please, neither on this, back to topic.
Report Abuse
FreeToTake is not online. FreeToTake
Joined: 21 Apr 2010
Total Posts: 1827
09 Nov 2012 02:58 PM
Actually as AFF said, it's all on the wiki :/
but however, here it comes :

game.Workspace:findPartOnRay(ray, user)

:findPartOnRay() is a method that requires 2 variables ;
the ray, (created with ray.new())
and the character (called user in the script)

it returns 2 things, the part it hit and the vector3 position of the hit.
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
09 Nov 2012 03:11 PM
I'm pretty sure the implied rule of this forum is to do research BEFORE you post. This means your post is spam. My help post is not spam.
Report Abuse
Fedorakid is not online. Fedorakid
Joined: 17 Jul 2010
Total Posts: 7079
09 Nov 2012 05:35 PM
I did try the wiki before i came here, u shouldnt be such a judger.
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