How do I access a specific object in Workspace by name on the client reliably?

This?

local MyObj = workspace:WaitForChild("Name")

The issue is what if someone called Name joins the game? Client replication order is not guaranteed, so this may get the object I want or get the character of a player of the same name. This is not a problem on the server though, because which object is gotten depends on which had their parent set to the common parent first, which is always the original object on the server, but due to the lack of guarantees about replication order, is not so clear on the client.

I know the odds that someone with the exact name as some critical object in my Workspace joining is exceedingly rare, but still, how can I fix?

Have you considered putting things into folders and then you know categorically that the object in that folder cannot be a player’s character?

1 Like

Well then, how do I access that folder?

This may be easily abused by exploiters since they can read and change client scripts, therefore I think you should use remote events to also verify this info on the server.

Why do you wish to do it on the client anyway? What is the reason?

You can check through the descendants of workspace and see who is named “Name”

for Every, obj in workspace:GetDescendants() do
if obj.Name == "Name" then
RE:FireServer() -- Verify this info on the server
end

The client handles animations, because tweening on the server is lame. But if the animations are associated with objects that also exist on the server, I need the client to be able to access objects that are descendants of Workspace. For example, I have a spells folder, and when a spell is added to the spells folder by the server, the client plays a fade-in animation via ChildAdded. But what if someone joins that has the same name as the folder?

I guess you can try making a unique name for each folder, maybe named by their userid?

But there is only one folder, on the server.

sorry i don’t have the best english im still taking lessons, hopefully someone else can fix ur problem.

if you really wanted to, you can just do

if myObj:IsA("Folder") then
    --code here
end

or name your folder less then 3 letters or more then 20.

1 Like