Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

take a model name and cut it in two seperate parts?

local id = script.Parent.ID.Value

local myname = game.Workspace:FindFirstChild("MyModel"..id)

I have a long script involving this problem so I created an example for the sake of time. there are models inside the workspace, the first part of the name is what the model is, the other part is the name of the owner of that model:

[[[ "name of model"..players name in a value ]]]

my current problem is I need to get the owner of a specific model but I want to leave the models name out. is there a way to basically cut a string name in half and use it seperately?

1 answer

✓ Accepted answer

To do this you would use:

string.sub('variable', i, j)

Where 'variable' is the string that you're trying to separate, i is the start of the string that you want to separate and j is where you want the string to stop cutting or just leave it out to get any part of the string after 'i'.

Ex:

local ex = "abcdefghijk"
print(string.sub(ex, 4))

This would print "defghijk" Ex 2:

local ex = "abcdefghijk"
print(string.sub(ex, 4, 8)

This example would print "defgh"

3 comments

0

thanks

0

though one more question does this work outside of the quotation marks?

0

This works only for strings. As long as what you're using is a string in some way, it should work. I'm not 100% sure on what you're asking though

This discussion is preserved as it was. New answers, comments, and votes are closed.