Failed to get object by calling World.FindObjectByName when the object in a child of ClientContext

hi, I followed the tutorial: Advanced Scripting in Core - Core Creator Hub and I have a problem. I can't get "RoundUI" by calling World.FindObjectByName("RoundUI") when the "RoundUI" is a child of "ClientContext". However, if "RoundUI" isn't a child of "ClientContext", I can get it by calling World.FindObjectByName("RoundUI")
I don't know why, thks.

Without knowing your hierarchy, I can't give a certain answer. However, make sure the script that you are running is also in a ClientContext. Otherwise, the script would be ran on the server and cannot see what the client sees.

Also, if you are not in our Discord server, I recommend joining as there are many of us that can help with any issues you may have with anything on Core.

hi, Nicholas_Foreman, thks very much.
When I move the script to a ClientContext, it works!
But in the tutorial, the code is as follows:
World.FindObjectByName("Game Settings"):SetNetworkedCustomProperty("gameOver", true)
for i = 3, 0, -1 do
Task.Wait(1)
roundUI = World.FindObjectByName("RoundUI")
roundUI.text = "New round in "..tostring(i).." seconds"
end
So the script has to run on the server to call SetNetworkedCustomProperty, but it also has to run on the client to get the UI element.
How to solve this problem? thks.

Ah, sorry. I didn't look at the tutorial you were following, my bad.
One of the Core employees (@standardcombo) was actually streaming him working on this tutorial today if you want to check it out here.

As for your question, you can keep both the script and UI out of a ClientContext as changing it from the server will automatically update it for all clients also.

There seems to be an issue with the tutorial (maybe, I do not know for sure) in which it is telling you to put the RoundUI in a ClientContext:

We'll call it RoundUI and make it a sibling to CoinUI , by also setting it as a child of your Client Context .

However, the script that it is telling you to edit the Tick function of is in a default/server context. Therefore, there is a conflict as the server cannot see what is in the client. I will notify Gabriel of this so that he can give any input and correct me if I'm wrong.

hi, Nicholas_Foreman. I kept both the script and UI out of a ClientContext and they worked. There should be an error in the tutorial. Thank you for helping me a lot! :slight_smile: