I am trying to edit this laser script which uses ray to see if the player is looking at a wall and so then creating a part from the player to the object that is looked at to prevent it clipping through walls,
What I am trying to achieve is how can I make a 1x1x1 part get created at the end of a ray than 1 large part being the laser so then I could run a beam from the ray part straight to my gun’s part.
local direction = Handle.CFrame.LookVector.Unit
local laserRay = Ray.new(script.Parent.LaserFrom.CFrame.p, direction * 1000)
local _,hitPos = workspace:FindPartOnRay(laserRay, direction, true, true)
local dist = (script.Parent.LaserFrom.CFrame.p - hitPos).magnitude
script.Parent.LaserTo.Position = hitPos
Try typing the ray direction with the handle CFrame position - Mouse hit position unit.
local mouse = player:GetMouse()
local laserRay = Ray.new(script.Parent.LaserFrom.CFrame.p, (mouse.Hit.p - script.Parent.LaserFrom.CFrame.p).unit * 1000)
local _,hitPos = workspace:FindPartOnRay(laserRay, script.Parent.LaseFrom, true, true) -- where
the direction was in here requires an instance. it ignores the instance.
local dist = (script.Parent.LaserFrom.CFrame.p - hitPos).magnitude
script.Parent.LaserTo.Position = hitPos