The Code:
local ignore = {}
for i,v in pairs(game.Players.LocalPlayer.Character:GetChildren()) do
if v:IsA(“BasePart”) then
table.insert(ignore,v)
end
end
local raycastParams = RaycastParams.new()
raycastParams.FilterDescendantsInstances = {ignore}
raycastParams.FilterType = Enum.RaycastFilterType.Exclude
raycastParams.IgnoreWater = true
local rayOrigin = game.Workspace.CurrentCamera.CFrame.Position
local rayDirection = Vector3.new((mouse.Hit.X-game.Workspace.CurrentCamera.CFrame.Position.X)*3+mouse.Hit.X
, (mouse.Hit.Y-game.Workspace.CurrentCamera.CFrame.Position.Y)*3+mouse.Hit.Y
, (mouse.Hit.Z-game.Workspace.CurrentCamera.CFrame.Position.Z)*3+mouse.Hit.Z
)
local raycastResult = nil
for i = 1,100 do
wait()
if raycastResult == nil then
raycastResult = workspace:Raycast(rayOrigin, rayDirection,raycastParams)
else
break
end
end
This is the raycast