When I call FindPartOnRayWithWhitelist on a part that has just been spawned, it doesn’t detect the part unless I add a delay before casting. This is not an issue with FindPartOnRayWithIgnoreList.
wait(0.5)
game.Workspace.ChildAdded:Connect(function(Part)
local Origin = Part.Position + Vector3.new(0, 1, 0)
local Ray1 = Ray.new(Origin, Vector3.new(0, -2, 0))
-- Works if there is a delay
-- wait(0.1)
local h, p = game.Workspace:FindPartOnRayWithWhitelist(Ray1, {Part})
print(h)
-- Prints nil with no delay
end)
wait(0.5)
local Part = Instance.new("Part")
Part.CFrame = CFrame.new(0, 10, 0)
Part.Anchored = true
Part.Parent = game.Workspace