i know the title isn't exactly the best, but i'll try to explain what i mean a bit better. so, say i have a starting point for my ray in one place, and the end point is behind a wall. the ray also draws a "laser", or a block that essentially visualizes the ray. what i don't want to happen is the laser to go through the wall, but instead stop when it hits the wall. in case i didn't explain it well enough in text form, check out this visual i drew up. this is the code i have so far, which draws the ray through anything without stopping. the part which deals with the size of the laser/ray is within the repeat block.
local tool = script.Parent
local player = game:GetService("Players").LocalPlayer
function DRAW()
local beam = Instance.new("Part")
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
beam.Parent = workspace
repeat
wait()
local point = game.Workspace.NinjaboySC.HumanoidRootPart
local ray = Ray.new(tool.CFrame.p, (point.Position - tool.CFrame.p).unit * 300)
local distance = (tool.CFrame.p - point.Position).magnitude
beam.Size = Vector3.new(0.3, 0.3, distance)
beam.CFrame = CFrame.new(tool.CFrame.p, point.Position) * CFrame.new(0, 0, -distance / 2)
until game.Workspace.NinjaboySC == nil
end
wait(3)
DRAW()

1 comment
You can use this to: workspace:FindPartOnRayWithIgnoreList(Ray, Ray_Ignore). I put the client's character, camera and trails/lasers in Ray_Ignore