" the raycasts 2nd parameter should be a direction pointing to where you want the ray to go"
In no way did I imply that you should just remove position.
You need to change it to a vector3 with the direction of where you want it to go and a magnitude of distance.
OOOH, you have to specify the distance inbetween the 2 parts for it to work. Thank you so much!!!
--fixed code
local ani005335 = game.Workspace:WaitForChild("ani005335")
local HumanoidRootPart = ani005335:WaitForChild("HumanoidRootPart")
local ani005335 = game.Workspace:WaitForChild("ani005335")
local HumanoidRootPart = ani005335:WaitForChild("HumanoidRootPart")
local RunService = game:GetService("RunService")
local part = script.Parent
local lookvector = HumanoidRootPart.CFrame.LookVector
local frame = part.Remorse.PrimaryPart
local pos = HumanoidRootPart.Position + HumanoidRootPart.CFrame.LookVector * 20
local bracket = {}
local RemoteEvent = game.ReplicatedStorage:WaitForChild("RemoteEvent")
local function VisualizeRay(partPos,direction)
local distance = direction.Magnitude
local midpoint = partPos.Position + direction / 2
local newPart = Instance.new("Part")
newPart.Anchored = true
newPart.CanCollide = false
newPart.Material = Enum.Material.Neon
newPart.Color = Color3.fromRGB(255,0,0)
newPart.Size = Vector3.new(0.2,0.2,distance+0.1)
newPart.CFrame = CFrame.new(midpoint,partPos.Position)
newPart.Parent = workspace
game.Debris:AddItem(newPart,0.5)
end
RunService.Stepped:Connect(function()
-- part:MoveTo(HumanoidRootPart.Position + (HumanoidRootPart.CFrame.LookVector * 100))
-- frame.CFrame = CFrame.new(pos, pos + lookvector)
local pivot = part:GetPivot()
local newPivot = CFrame.lookAt(HumanoidRootPart.Position + (HumanoidRootPart.CFrame.LookVector * 30),HumanoidRootPart.Position)
part:PivotTo(newPivot)
for i,v in pairs(part.Remorse["Visual Range"]:GetChildren()) do
local raycastparams1 = RaycastParams.new()
raycastparams1.FilterType = Enum.RaycastFilterType.Exclude
raycastparams1.FilterDescendantsInstances = {part,HumanoidRootPart,HumanoidRootPart.Parent.Square}
local raycast = workspace:Raycast(HumanoidRootPart.Position,v.Position-HumanoidRootPart.Position)
--The script above is what I changed
VisualizeRay(HumanoidRootPart,v.Position-HumanoidRootPart.Position)
if raycast and (raycast.Instance.Name == "Part") == false then
print(raycast.Distance)
print(raycast.Instance)
else
warn("EAT BUGS")
end
end
end)