Im confused about how to manipulate raycast to make my own weapons, someone pls help because i want to stop using fe guns and make my owns.
COMMUNITY QUESTION
How do you manipulate Ray Casting?
1 answer
First, we need to figure out what a ray does.
ray = Ray.new(Origin, Direction)
Origin, means the original point that the ray cast from. You can imagine it as 0,0,0 of the object space.
Direction, where the ray ends from its origin. You can imagine it as the arrow pointing out from 0,0,0(Origin).
Time for some examples!
--Basic--
local ray = Ray.new(Vector3.new(1,1,1),Vector3.new(0,1,0))
--It means the ray casts from 1,1,1
--to 1,2,1
--(1,1,1) + (0,1,0)
--[[Direction from look vector]]--
local castRange = 500--It will be used soon
local part = Instance.new("Part",game.Workspace)
part.Anchored = true
part.Color = Color3.new(1,.6,1)
part.Size = Vector3.new(1,1,1)
--Z = Front
local ray2 = Ray.new(part.Position,part.CFrame.LookVector * castRange)
--Notice:
--LookVector * castRange means to
--cast the ray from the position of the part to the direction
--which stretches to 500 studs from where the part faces
More details: DevForum similar post
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
basically two connecting points, Ray.new(vector1,vector2), just a line that connects from those points, you can find the part that hit it first, shooting would be a whole other thing though if you are making a gun