Can't get MeshPart from ReplicatedStorage

Hi,

I have a problem with ReplicatedStorage. I am storing a bunch of MeshParts but whenever I try to access them they just show up as nil.

Here is my code:

local module = {}

local rep = game:GetService("ReplicatedStorage")
local numbers = rep:WaitForChild("Numbers"):GetChildren()

-- 10746979335

function module.charToMeshPart(char)
	local ascii = string.byte(char)
	local thing = numbers["ASCII"..tostring(ascii)] or numbers["ERR"]
	
	if not thing then
		warn("No mesh found")
		warn("NAME: ".."ASCII"..tostring(ascii))
	end
	
	print(thing)
	
	return thing
end

and this is my “structure”:

image

and here are my logs:

I thought that MeshParts were not replicated for a minute but I couldn’t find anything on Google or the documentation about it. Please help.

EDIT: I checked and the length of the numbers array is 11.

1 Like

local numbers = rep:WaitForChild(“Numbers”):GetChildren()

numbers becomes a table

.

numbers[“ASCII”…tostring(ascii)]

You attempt to access numbers as though it was a dictionary.


Try removing GetChildren() when defining numbers, as well as switching from numbers[“… to numbers:FindFirstChild(”…, and see if it resolves your issue

1 Like

Hi, thanks for trying lol

I tried changing the code to use FindFirstChild and WaitForChild with a 5 second timeout, yet the same thing happens for some of the MeshParts.

Logs

New Code

local module = {}

local rep = game:GetService("ReplicatedStorage")
local numbers = rep:WaitForChild("Numbers")

function module.charToMeshPart(char)
	local ascii = string.byte(char)
	local thing = numbers:WaitForChild("ASCII"..tostring(ascii), 5) or numbers:FindFirstChild("ERR")
	
	if not thing then
		warn("No mesh found")
		warn("NAME: ".."ASCII"..tostring(ascii))
	end
	
	print(thing)
	
	return thing
end

I just found the issue.

Turns out in another part of the script I was calling that function and then using that result and parenting it somewhere else instead of cloning it first, so the next time it was accessed it wasn’t there.

Sorry! lol

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.