A simple piece of code does not work

Hi developers,

I’ve recently came across this line of code that doesn’t work for some odd reason. It keeps not finding the “Part” when it’s in the descendant of where it is scripted to GetDescendants().

Code:

for i,v in pairs(script.Parent:GetDescendants()) do
	if v:IsA("Part") then
		print("FOUND YES")
		table.insert(uno, v.Name) -- uno is a table
	else
		print("NOT FOUND OOF #1")
	end
end

Is this a studio bug? Or is there such things as a limit for GetDescendants()?

Have you tried using "BasePart" instead?

Yes, it still doesn’t want to work.

I have tried this code and it works fine for me. I tried it with a table and a few parts in the script.

Could it be something else in my script?

Try using a few prints to make sure your script is running.

It’s running alright. Any other suggestions?

Can you show your explorer that contains the script?

Which script is your problem? (The name of the script)

SaveDATA is the script name not LoadData.

I don’t see any BasePart inside Slots frame.

image

AWTetr7erwsh5w4h

It appears 30s after you press play

Which service is it parented in?

PlayerGui, is this the reason?

GUIs should be handle locally, aka local script.

Only local scripts run in starter gui. You should parent the script to server script service or any other area where scripts can run.

While scripts do run in playerGui, it is only for backwards compatibility purposes.
Try using remote events

Huh, it’s still not working when I re-scripted it.

Eitwrieahuiaeioea4r

I’ll try adding remote events.

this sounds like client-server shenanigans. Make sure you’re not trying to read an instance that is server only on the client, and vice versa. I’d need to see the entire rest of your game to give a fully informed input.

IIRC, the “green” bar is server, so if youre expecting a “part” input from the server on the client - you won’t get it, and if you’re expecting a part input from the client “on the server”, you won’t get it.