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

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

Asked by 5 years ago
Edited 5 years ago

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.

0
Why are you defining a variable, when you don't even use it? Miniller 562 — 5y
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 Protogen_Dev 268 — 5y

3 answers

Log in to vote
1
Answered by 5 years ago

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)
0
thank you Protogen_Dev 268 — 5y
Ad
Log in to vote
1
Answered by
Antelear 185
2 years ago

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.

0
That is late but this is going to be helpful to make some admin commands. Protogen_Dev 268 — 2y
0
glad it helped x3 Antelear 185 — 2y
Log in to vote
-3
Answered by
kom297 -4
5 years ago

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

local name = game.Name

print(name)
0
-1, thats literally what he wrote in his question. theking48989987 2147 — 5y
0
Well it worked for me so i answered with what i did kom297 -4 — 5y
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" Protogen_Dev 268 — 5y
0
If you are not sure that this is the answer then write just a comment Miniller 562 — 5y
0
you aren't sure of the answer either miniller ur always giving dumb answers User#24403 69 — 5y

Answer this question