Scripting Helpers is winding down operations and is now read-only. More info→
Log in to vote

Is there any way to search a object names based off userId? (only part of the name is the id)

Asked by 8 years ago

I have names some objects in my game as there userId then the name of the object. I thought this would help me track but I am not sure how I would find them based off the userId. I thought it would be with string.sub or string.len but I cant find a way to get it to work.

1 answer

Log in to vote
Answered by
SurVur 86
8 years ago
stuff = game.Workspace:GetChildren()
--or wherever you have your objects

for _,v in ipairs(stuff) do
    if v.Name:find(tostring(PlayerUserId)) then
        table.insert(TableOfStuff, v)

return TableOfStuff

I am assuming that you know what the userId is

:D This is what I needed. Have to modify it a bit. Thank you so much SurVur! thedarkdays152 0 — 8y

Answer this question