My code is intended to keep the circle on the floor a certain distance from the player (depending on where the mouse is located) with a min and max distance. It works as intended, except that if any objects are caught in the cursor, the script readjusts for an unintended target. Is there a way I can readjust the position to not be affected by parts caught by the cursor?
game_run_service.RenderStepped:Connect(function()
if ready == true then
m.TargetFilter = handle
local mpos = m.Hit.Position
local dist = (mpos - char.HumanoidRootPart.Position).magnitude
if dist < 3.5 then
dist = 3.5
end
if dist > 15 then
dist = 15
end
--print(dist)
handle.Position = char.HumanoidRootPart.Position + (char.HumanoidRootPart.CFrame.lookVector * dist) - Vector3.new(0,3,0)
end
end)
