How would I go about making this ray cast from a part (script.Parent.Shoot) to the part my mouse is on?
local function semiResult(x, y)
local unitRay = camera:ScreenPointToRay(mouse.x, mouse.y)
return workspace:Raycast(unitRay.Origin, unitRay.Direction * 500, semiParams)
end
Get the part of the raycast and use the cframe.new(Position, Lookat)
constructor to get a cframe that comes from the part you want to raycast from to the part your mouse is at.
Example:
local Part = semiResult(MousePos)
if Part then
Part = Part.Instance
local NewCF = CFrame.new(Shoot.Position, Part.Position)
local RaycastResult = workspace:Raycast(Shoot.Position, NewCF.LookVector * Range)
--do whatever you wanted to do with the raycast
end