I have this script that finds all the players in game and sends blocks created earlier in the script (x) after the player, so far everything works but only goes after one specific player, it doesn't go after the nearest, the target could be incredibly far away but would still only go after that one player as long as they're in range (range was changed for testing purposes)
spawn(function()
local part = x
for _, v in next, workspace:GetChildren() do
if v:FindFirstChild("HumanoidRootPart") ~= nil and v:FindFirstChild("Humanoid") ~= pchar.Humanoid then
local range = 25000
if (v.HumanoidRootPart.Position - x.Position).magnitude < range then
found = true
x.Anchored = false
for i = 1, 40, 0.01 do
bv.Velocity = (v.HumanoidRootPart.Position - part.Position).unit * 30
part.CFrame = CFrame.new(part.Position, v.HumanoidRootPart.Position) * CFrame.Angles(0, 80, 0)
wait(0.02)
end
end
end
end
end)
can someone help me make it find the nearest player? i can't really find out so i need help lol
