now i have other problem. the random children that chosen can be the script and then it can remove it. that mean my script wont work if the random children will be chosen as the script
what i can do? can i filter that only ClassName “Parts” will be chosen? if yes how
Have it check if the instance IsA(“script”) or have it check the name. If name is script, then don’t delete, instead rerun the code.
Or just have the model being a child of the script.
Or check the position of the script in the table of the children. And then have it give you another random number if the # of the script is given.
I guess: local RandomItemRemove=ChoosenMapCloneChildrens[math.random(1,#ChoosenMapCloneChildrens)] while RandomItemRemove==nil or RandomItemRemove:IsA("Script")do RandomItemRemove=ChoosenMapCloneChildrens[math.random(1,#ChoosenMapCloneChildrens)] wait() end
You could also use this but I won’t recommed looping through everything. I guess it’ll be more
“expensive” as it loops through all children. I’m not too sure but this would only be useful if you want to skip extra “wait()'s”: local ChoosenMapCloneChildrens for _,AmIAScriptOrNot_Hmmm in pairs(ChoosenMapClone:GetChildren()) if not AmIAScriptOrNot_Hmmm:IsA("Script")then ChoosenMapCloneChildrens[#ChoosenMapCloneChildrens+1]=AmIAScriptOrNot_Hmmm end end
Yeah, precisely what I meant ^
But for future use, I think just remember when your scripts can and can’t fire. And it always is worth a check with :IsA()!