How do I make FindFirstChildWhichIsA searches a new Model

the point is how to get the server to find
Model first from GrassFolder before continuing the script

local grass = workspace.GrassFolder:FindFirstChildWhichIsA(“Model”)
after
local grass = workspace.GrassFolder:FindFirstChildWhichIsA(“Model”)
then
wait(1)

more precisely like this

the point is how to get the server to find
Model first from GrassFolder before continuing the script

local grass = workspace.GrassFolder:FindFirstChildWhichIsA(“Model”)
after
local grass = workspace.GrassFolder:FindFirstChildWhichIsA(“Model”)
then
wait(1)

more precisely like this

Why not just have the script which clones the thing fire a bindable event or signal and another script receives this info?

1 Like

I haven’t learned much about remote events and bindables so far, so I’m not too familiar with events.

1 Like

I’ll be able to make a script that might be able to work for you! FIrst, is this a server script or local script?

1 Like
local grass 

repeat 
grass = workspace.GrassFolder:FindFirstChildWhichIsA(“Model”)
task.wait()
until grass

stop trying to make it complicated, remote events and bindables are not needed, and will mess with performance, just use this.


also, @AamTum, use task.wait(). wait() is deprecated and should never be used in modern projects.
task.wait() is the same but more accurate and just a overall better practice.

2 Likes

it’s a server script
local grass = workspace.GrassFolder:FindFirstChildWhichIsA(“Model”)

Okie, try what the person above said though, I think that’s a great solution!

1 Like

I have tried using it, but when @WickdSuper @PieFaceChamp_2

(btw i put this script on moduleScript)

local grass 
repeat 
grass = workspace.GrassFolder:FindFirstChildWhichIsA(“Model”)
task.wait()
until grass

when the old :FindFirstChildWhichIsA(“Model”) grass is destroyed (by server caused by other script)
and new cloned grass by other script gave me an error
Grass1 is not a valid member of Folder “GrassFolder”

yeah, thats because whenever something is destroyed then the parent becomes nil (its gone)
so youd have to check for when the grass is destroyed to define a new grass
ex:

local grass 

local function GetGrass()
repeat 
   grass = workspace.GrassFolder:FindFirstChildWhichIsA(“Model”)
   task.wait()
until grass
end)

grass.Destroying:Connect(function()
    GetGrass()
end)

it gave me an error
ReplicateStorage.Module:10: attempt to index nil with ‘Destroying’

sorry, put it in the wrong spot, my fault

local grass 

local function GetGrass()
repeat 
   grass = workspace.GrassFolder:FindFirstChildWhichIsA(“Model”)
   task.wait()
until grass

grass.Destroying:Connect(function()
    GetGrass()
end)

end)

It still gives me an error, which results in not being able to detect grass children.

how do I make it so that when the rig is destroyed it will connectthe GetGrass function

Events are an amazing skill to learn

yea i agree, but many say that because of remoteevent exploits can control your game.