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

How would I remove a bit of text from a string?

This is kinda linked to my past question. When I run the script to print the name of the game as follows:

local Name = game.Name

print(game.Name)

It decides to print "Development @ 22 Feb 2019 17:21"

What i need to do is remove everything but the name "Development"

Bearing in mind this is being tested in studio so if this doesnt happen when run during an actual game please tell me that to.

2 comments

0

Why are you defining a variable, when you don't even use it?

0

It was just a small mistake in the typeing of the code. Where it says game.Name in the print its ment to say Name

3 answers

✓ Accepted answer

use string.sub to cut off the rest of the name ((you may have to adjust this if the length of the actual place name changes

local originalName = game.Name
local newName = string.sub(originalName,1,11)

1 comment

0

thank you

I know I'm 3 years late but;

local Split = string.split(game.Name, " ")
print(Split[1])

-- split pretty much returns a table of all given strings seperated via a space inbetween, but could be anything for example "-" or ".". Doesn't matter really.

Hope this helps too.

2 comments

0

That is late but this is going to be helpful to make some admin commands.

0

glad it helped x3

I'm not sure if this will answer your problem but this is what I did

local name = game.Name

print(name)

5 comments

0

-1, thats literally what he wrote in his question.

0

Well it worked for me so i answered with what i did

0

Did you test that in a game or in studio cause run through a local script inside of my game it just printed "Game"

0

If you are not sure that this is the answer then write just a comment

0

you aren't sure of the answer either miniller ur always giving dumb answers

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