i'm making a script that is supposed to find a bunch of parts near a player and chose one but i'm not sure of how to do it.
i've tried a bunch of techniques but i cant figure it out
here is a error message on the output BotScript:12: attempt to call method 'GetChildren' (a nil value)
and here is the script for it
local char = game.Workspace:FindFirstChild(plr.Name)
local mines = game.Workspace.Mines:FindFirstChild(plr.HidenStats.Working.Value).Folder
local closeSpots = {}
for i,v in pairs (mines:GetChildren())do
if (char:FindFirstChild("HumanoidRootPart").Position-v.Position).Magnitude <= 20 then
table.insert(closeSpots,i,v)
end
end
local randomSpot = math.random(1,#closeSpots:GetChildren())
local chosen = mines[randomSpot]

4 comments
use absolute value line 08
@greatneil no need, magnitude is always positive
try wait for child instead of find first child on line 3
this is just an example of a bigger script