Help with instantiate ()

Godot Version

i’m new to godot and i’m struggling to finding a command. Looked up in videos and other documentation but i can’t find it.

Basically i’m generating a map based on fastnoise lite:

I can set the tilemap ti have trees and other thing but i would like to use .tscn files instead.

When i’m trying to instantiate i can’t correctly script the part where the map comunicate the Vectors to the instantiate().

i’'ve preloaded the correct scene.

i was looking for one of two solutions:

func trees():
frot in trees_spawn_num: # var setupped before.
var instance_trees = tree.instantiate()
instance_trees_position = getRandomPosition() # randomized function

this is working but it’s placing trees on water. How can ti limit that random function only on a specific tileset?

Create the map i’m using noise. One noise for the terrain and one for trees.
I can’t find the correct command to instantiate on fastnoiselite noise.

i’ve this code atm:

func world()
for x in range(-width/2, width/2)
for y in range(-height/2 , height/2)
var noise_val : float = noise.get_noise_2d(x,y)
vat tree_noise_val : float = noise.get_noise_2d (x,y)
if noise_val > 0.05 and tree_noise_val > 0.0
t_tiles _arr-append(Vector2i(x,y))


world_tileset.set_cell_terrain_connect(Layer1, t_tiles…etcetc)

What kind of command should i use and how to instantiate trees.tscn in the correct position ?

it’s been two weeks and i still can’t find a single video that shows or use that line of code to instance scenes in this way.

Any help is very appreciated ! Ty!