so i got this code
local pos = target.PrimaryPart.Position
model.PrimaryPart.CFrame = CFrame.new(model.HumanoidRootPart.Position,Vector3.new(pos.X,model.HumanoidRootPart.Position.Y,pos.Z))
what it does is rotate my model to the given position but the problem is when i use :Dot function, it return distance between target’s position itself not the distance between model and target
also here’s the code i use
local result = {}
for i,v in pairs(list) do
if v.HumanoidRootPart and v.Humanoid then
local pos = v.HumanoidRootPart.Position
local preferredDirection = CFrame.new(tower.HumanoidRootPart.Position).LookVector
local deltaPosition = pos -tower.HumanoidRootPart.Position
local actualDirection = deltaPosition.Unit
local distance = deltaPosition.Magnitude
local angleDifference = math.acos(actualDirection:Dot(preferredDirection))
local Angle = tower.Power:FindFirstChild('ConeAngle')
if distance < minrange and math.deg(angleDifference) < Angle.Value then
result[#result+1] = v
end
end
end
return result
anyone know how to fix this?