A simple piece of code does not work

First, lets clear some confusion about local scripts in the UI. Both scripts and local scripts run on playerGui, due to behavior documented here. But programming UI and user input relations on client is the most popular practice (and for pretty good reasons).

As said above, the problem is probably client-server replication trickery. Check the code which creates the part instance. If that is run on a local script, the part does not exist on the server, so the code you’re running on server will not find it. You can also toggle client and server on test mode in studio to check this.

For a fix, design the model so that the part is created on server and checked on (anything [except other players’ clients]), or is created on client and checked on client.

Remote events will come into play if you want a local script to request the server to do something on its behalf. A local script can fire a remote event to tell the server to make an instance, but it cannot create the instance itself and pass that in as a parameter telling the server it exists.

Hope this was a useful expansion on the solutions outlined above.

Maybe try doing :GetChildren() instead of :GetDescendants()

1 Like

Its so obvious, there is no part in StarterGui.

That is incorrect.
Serverscripts can run there as well, however they shouldn’t be there.