if hitPart.Parent:FindFirstChild("Humanoid") then
print(hitPart.Name)
local playerPosition = player.Character.PrimaryPart.Position
hitPart.Anchored = false
local bodyVelocity = Instance.new("BodyVelocity")
bodyVelocity.Velocity = (playerPosition - hitPart.Position).unit * abilitySettings.Abilities[3].speed
bodyVelocity.MaxForce = Vector3.new(400000, 400000, 400000)
bodyVelocity.Parent = hitPart
local stoppingDistance = abilitySettings.Abilities[3].stoppingDistance -- Максимальное расстояние, при котором объект остановится от игрока
local connection
connection = RunService.Heartbeat:Connect(function()
local currentDistance = (player.Character.PrimaryPart.Position - hitPart.Position).magnitude
if currentDistance <= stoppingDistance then
bodyVelocity:Destroy()
if connection then
connection:Disconnect()
end
end
end)
end
So the problem is when I want to attract a player, it doesn’t work, but when a npc it works. And at the same time in the prints of the nps is written HRP, and the player any other party, so what am I doing wrong?