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: How would i do this with loops?

Previous Thread :: Next Thread 
xlaser23 is not online. xlaser23
Joined: 10 Dec 2011
Total Posts: 20341
24 Sep 2015 03:56 PM
part.name ="h"
wait(.1)
part.name = "hi"



http://www.roblox.com/xla-item?id=290739801http://www.roblox.com/aser-item?id=290739819http://www.roblox.com/23-item?id=290739831 R$639 Tx1,818
Report Abuse
Stymi is not online. Stymi
Joined: 19 Sep 2015
Total Posts: 1077
24 Sep 2015 03:57 PM
for i = 1, #str do
text = text..str:sub(i, i)
end
Report Abuse
BusyCityGuy is not online. BusyCityGuy
Joined: 17 Aug 2012
Total Posts: 2144
24 Sep 2015 03:57 PM
That's the most efficient way to do it if you only have 2 strings like that.

-The [Guy]
Report Abuse
BusyCityGuy is not online. BusyCityGuy
Joined: 17 Aug 2012
Total Posts: 2144
24 Sep 2015 03:59 PM
If you want a word to spell itself out:

local str = "hello"
for i = 1, #str do
text = text..str:sub(1, i)
end

> h
> he
> hel
> hell
> hello

previous poster would have output:

> h
> e
> l
> l
> o

-The [Guy]
Report Abuse
BusyCityGuy is not online. BusyCityGuy
Joined: 17 Aug 2012
Total Posts: 2144
24 Sep 2015 04:00 PM
Sorry I didn't read his code carefully. His code was fine. Lol my code wouldn't work, it would get really messed up.

Either this:
local str = "hello"
for i = 1, #str do
text = text..str:sub(i, i)
end

or this:
local str = "hello"
for i = 1, #str do
text = text:sub(1, i)
end

will work fine.

-The [Guy]
Report Abuse
Stymi is not online. Stymi
Joined: 19 Sep 2015
Total Posts: 1077
24 Sep 2015 04:00 PM
Uhhhh no, no I wouldn't.
Report Abuse
BusyCityGuy is not online. BusyCityGuy
Joined: 17 Aug 2012
Total Posts: 2144
24 Sep 2015 04:01 PM
I corrected myself, I read your code wrong at first.

-The [Guy]
Report Abuse
InsaneDays is not online. InsaneDays
Joined: 28 Jan 2012
Total Posts: 762
24 Sep 2015 04:02 PM
for i = 1,string.len(text) do
Whatever.Name = string.sub(text,1,i)
end
Report Abuse
Stymi is not online. Stymi
Joined: 19 Sep 2015
Total Posts: 1077
24 Sep 2015 04:03 PM
first one is fine what are you trying to accomplish insane
Report Abuse
xlaser23 is not online. xlaser23
Joined: 10 Dec 2011
Total Posts: 20341
24 Sep 2015 04:08 PM
@sty
local text = "derp"

for i = 1, #str do
script.Parent.Text = text..str:sub(i, i)
end


>Str is unkown



http://www.roblox.com/xla-item?id=290739801http://www.roblox.com/aser-item?id=290739819http://www.roblox.com/23-item?id=290739831 R$639 Tx1,818
Report Abuse
BusyCityGuy is not online. BusyCityGuy
Joined: 17 Aug 2012
Total Posts: 2144
24 Sep 2015 04:09 PM
you defined your variable as "text" and you tried to call it "str"... be consistant yo :P
Also you probably want the wait(.1) in your loop so it doesn't write it all at once.

-The [Guy]
Report Abuse
InsaneDays is not online. InsaneDays
Joined: 28 Jan 2012
Total Posts: 762
24 Sep 2015 04:09 PM
Use mine.
Report Abuse
BusyCityGuy is not online. BusyCityGuy
Joined: 17 Aug 2012
Total Posts: 2144
24 Sep 2015 04:11 PM
Insane, you literally posted the same thing I did, but used string.len() instead of # lol

local text = "hello"

for i = 1, #text do
part.Name = text:sub(1,i)
wait(.1)
end

thats about the best it gets. :P

-The [Guy]
Report Abuse
Stymi is not online. Stymi
Joined: 19 Sep 2015
Total Posts: 1077
24 Sep 2015 04:11 PM
No, busy. Str is the name of the string to add and text is the original value. You could change it to object.Name, or whatveer you want.

"Use mine."

What is so much better about yours lmao?

@xlaser

Don't expect all code to be handed on a silver platter. OBVIOUSLY, you need to define variables and an object reference.
Report Abuse
xlaser23 is not online. xlaser23
Joined: 10 Dec 2011
Total Posts: 20341
24 Sep 2015 04:12 PM
mmmk i got it Ty



http://www.roblox.com/xla-item?id=290739801http://www.roblox.com/aser-item?id=290739819http://www.roblox.com/23-item?id=290739831 R$639 Tx1,818
Report Abuse
xlaser23 is not online. xlaser23
Joined: 10 Dec 2011
Total Posts: 20341
24 Sep 2015 04:13 PM
"Don't expect all code to be handed on a silver platter. OBVIOUSLY, you need to define variables and an object reference."


uh

i have no responce



http://www.roblox.com/xla-item?id=290739801http://www.roblox.com/aser-item?id=290739819http://www.roblox.com/23-item?id=290739831 R$639 Tx1,818
Report Abuse
InsaneDays is not online. InsaneDays
Joined: 28 Jan 2012
Total Posts: 762
24 Sep 2015 04:14 PM
@BusyCity, Didn't even read. gone straight for the answer.
Report Abuse
BusyCityGuy is not online. BusyCityGuy
Joined: 17 Aug 2012
Total Posts: 2144
24 Sep 2015 04:16 PM
@insane Gotcha.
@OP We were all a little unclear on your intentions. Try to state what you need a little better in your post.

-The [Guy]
Report Abuse
InsaneDays is not online. InsaneDays
Joined: 28 Jan 2012
Total Posts: 762
25 Sep 2015 05:41 AM
Stymi, your script may have a downside.

If a part you're about to rename is already named, it won't reset it.

like:

local part = Instance.new("Part", game.Workspace)
local text = part.Name
local str = "Idk"

for i = 1, #str do
text = text..str:sub(i, i)
wait()
end

Final Result: PartIdk

Just stating it.
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