Can locally generated instances be referenced by other local scripts?

If i create a part with a localscript can it be used in other local scripts?

I’d assume so, as long as they’re handled on the Local Side & named fine

local Part = Instance.new("Part")
Part.Name = "ThisIsAPart"
Part.Parent = workspace
--Other LocalScript
local Part = workspace:WaitForChild("ThisIsAPart")
print(Part)
2 Likes


Ok, but then why does this return nil, and how could i solve it?

local ObjectToClone = game.Workspace.Ignore:WaitForChild("SelectBox"):FindFirstChildWhichIsA("ObjectValue").Value

Yes. So long as the LocalScripts in question are running from the same client.

2 Likes

Try doing this instead

local Object = workspace.Ignore:WaitForChild("SelectBox")
local Check = Object:FindFirstChildWhichIsA("ObjectValue")

if Check then
    print("Yes")
else
    print("No")
end

It prints out no :(( :shallow_pan_of_food:

Oh wait looking at the picture you should be attempting to get through all of the Descendants, you’re attempting to find something inside the SelectBox alone which keeps returning back nil cause there’s no ObjectValue inside the SelectBox’s Children when you should be searching inside the Model instead

image

local Object = workspace.Ignore:WaitForChild("SelectBox"):WaitForChild("ModelToPlace")
local Check = Object:FindFirstChildWhichIsA("ObjectValue")

if Check then
    print("Yes")
else
    print("No")
end

wasn’t :FindFirstDescendantWhichIsA() a thing?

I believe you might be referring to this?

Weird, I swear i have used the function at least once i swear.

As long as the other scripts that want to use the part are also local scripts then you should be fine.

Yes :shallow_pan_of_food: :shallow_pan_of_food: