In my single player game, I want to make a grass field for the player to walk in, but since the field is so big, I want to make a script that will load in only grass that is near you. What I want to happen, is that whenever a player gets close enough (230 studs) to an invisible part in the model 'GrassPatchSpawnPoints', the script will get a model called 'GrassPatch' from ScriptStorage and place it at the position of that invisible part. Whenever I load it in, output is telling me that line 3 is an attempt to index a nil value. I need to figure out how to identify to position of the player as a value, so then the script can compare the number of the distance of the character to a part. What should I do?? I'm a beginner so if it looks stupid, please don't be harsh.
distance = 230 --num value to studs "put radius in stud metric"
avatar = game.Players:FindFirstChildOfClass("Player").Position
GrassSpawn = workspace.GrassPatchSpawnPoints:GetChildren()
for g=1, #GrassSpawn do
gspawn = GrassSpawn[g]
end
A = avatar
B = gspawn.Position
if (A - B).magnitude <= distance then
gClone = game.ServerStorage.GrassPatchClone:Clone()
gClone.parent = workspace
gClone.Position = B
gClone.Rotation = Vector3.new(0,math.random(0,175),0)
else
gspawn.transparency = 1
end

3 comments
The physics engine still has to handle parts, even if they are transparent. I suggest destroying them and placing them back in.
Position is not a property of player, rather player.Character["Head"]
it still doesn't work. currently at line 3 it says
avatar = game.Players:FindFirstChildOfClass("Player").Character["Head"].Position