I have a few progress systems which are duplicated for every player, the issue is that it can cause a bit of lag, so I am trying to destroy it for the local player. I can do that, the issue is that I don’t know how to find the prefix of the string.
So, each time it’s duplicated for each player, on the server’s side, its name is “progress(user’s id)”. How would I find if the name starts with “progress”?
I tried doing some research, and found string:find(), however that seems to not be in the Roblox Lua library. Where do I go from here?
No, that is what it prints. Basically, it returns the start of the match and the end. So, ell starts 2 characters in and ends 4 characters in. If it doesn’t find it, it returns nil. So, to catch that, you can do:
local str = "progress123"
if str:find("progress") then -- found, or else it would be nil
local id, _ = str:gsub("progress", "") -- get the id as well
print(id)
end
Another approach would be to see whether the id is contained in there instead of finding out whether ‘progress’ is.
if str:match("%d") then
print(str:match("%d+")) -- gets the id, %w+ for all of it
end