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 » Scripting Helpers
Home Search
 

Re: How would i..

Previous Thread :: Next Thread 
Fedorakid is not online. Fedorakid
Joined: 17 Jul 2010
Total Posts: 7079
06 Nov 2012 08:55 AM
How would i delete an object that the name starts with "Map", the name isnt map its Map1 and Map2, but i want to delete everything that starts with Map, its something about string.sub right?
Report Abuse
MrChubbs is not online. MrChubbs
Joined: 14 Oct 2010
Total Posts: 4969
06 Nov 2012 09:01 AM
T = workspace:GetChildren()
for i = 1, #T do
if T[i]:sub(1, 3):lower == "map" then
T[i]:Destroy()
end
end

try this, it should work.
Report Abuse
lombardo2 is not online. lombardo2
Joined: 30 Nov 2008
Total Posts: 1604
06 Nov 2012 09:03 AM
Would work, but you forget to get the name T[i].Name

for k,v in pairs(Workspace:GetChildren()) do
if v.Name:lower():sub(1,3) == "map" then
v:Destroy()
end
end
Report Abuse
thedeathmaster01 is not online. thedeathmaster01
Joined: 14 Mar 2010
Total Posts: 6331
06 Nov 2012 09:27 AM
Lol just do this

for _,v in pairs(workspace:GetChildren()) do
if string.match(v.Name, "map") then
v:Destroy()
end;end
Report Abuse
Fedorakid is not online. Fedorakid
Joined: 17 Jul 2010
Total Posts: 7079
06 Nov 2012 10:17 AM
@Death, does string.match match words or also letters, because if not that will delete "map" and not map that starts with map.
Report Abuse
lombardo2 is not online. lombardo2
Joined: 30 Nov 2008
Total Posts: 1604
06 Nov 2012 10:55 AM
No, match uses regular expressions, to delete just map you use the pattern "^map$" with "map" it returns if the string contains "map" like "adsadsmapasa" or "map1"
Report Abuse
MrChubbs is not online. MrChubbs
Joined: 14 Oct 2010
Total Posts: 4969
06 Nov 2012 11:02 AM
Woops, I did totally noob out and forget T[i].Name, well my works just throw in the .Name before :sub(1, 3) and it will work for you. But don't use match, it could potentially delete things you don't want it to.
Report Abuse
lombardo2 is not online. lombardo2
Joined: 30 Nov 2008
Total Posts: 1604
06 Nov 2012 11:07 AM
^A lot of people prefer sub over match, even for commands. I prefer to use match, if you are good with regular expressions you shouldn't get unexpected results.
Report Abuse
MrChubbs is not online. MrChubbs
Joined: 14 Oct 2010
Total Posts: 4969
06 Nov 2012 11:14 AM
Well I try to give out things that are sure to work, though frankly match is better to use in general if it doesn't matter where the word appears. I use sub alot though for things such as my linux terminal emulator(Derpbian, best and only linux emulator on Roblox) and my chat system at samurai feud III(Corrects grammar to an extent, and bans noobs ;) ) so it is more a force of habit for me to go with sub rather than match.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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