generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: [Q] How can i change first letter of string

Previous Thread :: Next Thread 
CaptainSource is not online. CaptainSource
Joined: 08 Jun 2013
Total Posts: 848
19 Jun 2015 03:13 PM
What i did is


local text = "hello world";

text:sub(1,1) = "b" -- it errors.


help pls..


AND WHAT IS POINT OF [Q] SERIOUSLY
Report Abuse
iSpecializinq is not online. iSpecializinq
Joined: 31 May 2015
Total Posts: 2182
19 Jun 2015 03:16 PM
Try this

local Text = "Testuinnnnn"

string.sub(Text,1,1) = "v"

Report Abuse
1999bailey is not online. 1999bailey
Joined: 25 Jan 2015
Total Posts: 396
19 Jun 2015 03:18 PM
Whats with the semi colon
Report Abuse
CaptainSource is not online. CaptainSource
Joined: 08 Jun 2013
Total Posts: 848
19 Jun 2015 03:18 PM
nope.
Report Abuse
camhorto is not online. camhorto
Joined: 18 Apr 2011
Total Posts: 32
19 Jun 2015 03:20 PM
It's probably a habit from other languages, specifically C-like ones. It works with Lua.
Report Abuse
CaptainSource is not online. CaptainSource
Joined: 08 Jun 2013
Total Posts: 848
19 Jun 2015 03:20 PM
a = 1
a = 1;


a = 1 ; b = 1

is fine


a = 1 b = 1 ugly


well look at wiki there was article ,thats how mine scripting looks
Report Abuse
EgoMoose is not online. EgoMoose
Joined: 04 Feb 2009
Total Posts: 2896
19 Jun 2015 03:21 PM
That's because that's not what string.sub does.

http://wiki.roblox.com/index.php?title=Function_dump/String_manipulation#string.sub

It returns the substring given the indexes provided. It doesn't actually substitute.
Report Abuse
jode6543 is not online. jode6543
Joined: 16 Jun 2009
Total Posts: 5363
19 Jun 2015 03:22 PM
No, don't try that. string.sub only returns the first letter; you can't change it through string.sub. Try this:

text = text:gsub(".", "b", 1)

gsub replaces the occurrences of http://wiki.roblox.com/index.php?title=String_patterns The first argument is the pattern to replace ("." means any character), the second is what to replace it with, and the third is how many occurrences to replace (the first one, in this case). There are multiple ways to do what you requested, by the way; this is just one option.
Report Abuse
CaptainSource is not online. CaptainSource
Joined: 08 Jun 2013
Total Posts: 848
19 Jun 2015 03:24 PM
my hero omg kisses cheek*
Report Abuse
BothAngles is not online. BothAngles
Joined: 01 Dec 2011
Total Posts: 9604
19 Jun 2015 03:34 PM
That's not a habit because I don't do it
Report Abuse
BothAngles is not online. BothAngles
Joined: 01 Dec 2011
Total Posts: 9604
19 Jun 2015 03:37 PM
Worded that incorrectly but that's still not a habit
Report Abuse
radar001 is not online. radar001
Joined: 04 Sep 2011
Total Posts: 718
19 Jun 2015 03:38 PM
Could string.match do the same?
Report Abuse
amanda is not online. amanda
Joined: 21 Nov 2006
Total Posts: 5925
19 Jun 2015 05:35 PM
http://pastebin.com/Qndiff7n
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image