Is this a normal thing?

I am working on a game and i have come across a bug i think i have a string with 200k characters and i am trying to get a character i already found a thing that should work but it doesn’t seam to work i get the error ServerScriptService.Remote:6: attempt to call a nil value.
this is the code i have
´´´
game.ReplicatedStorage.Remote.GetItemCountFromId.OnServerInvoke = function(player, id)
local inventory = game.Players:FindFirstChild(player.Name).stats.inventory.Value
local value = “”

for i = (id - 1) * 10 + 1, id * 10 do
	value = (value)..(string.at(inventory, i))
end

return tonumber(value)

end
´´´
the inventory string is just zero’s 200k of them.
it is called from a local script.
i don’t need to know why it doesn’t work i just need a solution.
the id = 1 in this case

i don’t know why the code thing is so broken just always happens to me

I have never heard such thing as a string.at function. Are there reasons as to how you knew string.at?

i know about it from this post on this forum https://devforum.roblox.com/t/adding-string-at-str-n-to-directly-index-a-character-in-string/43653

Just because it is in Engine Features doesn’t mean there is such function, nor it is added already.

but i can’t find any other and i have tryed all on it and i know that it might not be a thing but wouldn’t it make an error if it didn’t exist.

What are you trying to in the inventory? You could use string.sub.

i am trying to get 10 charactors of the inventory and the id is what says the starting point so when id is 1 the charactors 1-10 are returned as a number. and when id is 2 it is the characters 11-20

for i = (id - 1) * 10 + 1, id * 10 do
	value = value..string.sub(inventory, i)
end

return tonumber(value)

thanks for helping me. i am a bit new so that is mostly the reason

1 Like