Hello i've been at this for a while now to little success. I want to have a raycast hit a block and reflect of it at 90 degrees. Below is the current mess of code i've come up with but it does not work as intended.
local function createBeam(part, point, surfacePoint)
print(part.Position)
if surfacePoint then
print(surfacePoint)
ray = Ray.new(point, surfacePoint * Vector3.new(1000,1000,1000))
else
print("no sp")
ray = Ray.new(point, part.CFrame.lookVector * Vector3.new(1000,1000,1000))
end
local newPart, newPoint, newSurfacePoint = workspace:FindPartOnRay(ray)
local beam = Instance.new("Part", workspace:WaitForChild("Beams"))
beam.BrickColor = BrickColor.new("Bright red")
beam.FormFactor = "Custom"
beam.Material = "Neon"
beam.Transparency = 0.25
beam.Anchored = true
beam.Locked = true
beam.CanCollide = false
local distance = (point - newPoint).magnitude
beam.Size = Vector3.new(0.3, 0.3, distance)
beam.CFrame = CFrame.new(point, newPoint) * CFrame.new(0, 0, -distance / 2)
if newPart then
wait(0.5)
createBeam(newPart, newPoint, newSurfacePoint)
else
print("Laser end")
end
wait(0.5)
end
