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
We use cookies to offer you a better experience. By using Roblox.com, you are agreeing to our Privacy and Cookie Policy.
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: I need help!

Previous Thread :: Next Thread 
ForgotTheFood is not online. ForgotTheFood
Joined: 25 Oct 2010
Total Posts: 801
08 Oct 2014 08:03 PM
I need help.
The problem is, I have roughly 100 or so hats. Those hats have parts in them (which all hats do) I need a script, to get the children of the workspace. Change the parts name within the hats to the hats name, and then move the part to the workspace.


HOWEVER I'M NOT A FLUID SCRIPTWRITER AND HAVE NO IDEA WHAT I'M DOING MOST OF THE TIME!
------------------

local parts = game.Workspace:GetChildren()
for i = 1,#parts do
if ((parts[i].className == "Part")) then
parts.Name = parts.Parent
parts.Parent = game.Workspace
end
end
wait(1)

------------------

That's what I think could do it, but I'm not sure. I haven't ran it yet, and think it won't work anyways, so Hopefully someone can help me fix it to work?

Report Abuse
Amnity is not online. Amnity
Joined: 27 Jan 2013
Total Posts: 39
08 Oct 2014 08:05 PM
local parts = game.Workspace:GetChildren()
for i = 1,#parts do
if ((parts[i].ClassName == "Part")) then
parts[i].Name = parts[i].Parent
parts[i].Parent = game.Workspace
end
end
wait(1)

Although I would like to point out that it will just make each child of Workspace that is the "Part" Class have the name "Workspace"
Report Abuse
lordrambo is not online. lordrambo
Joined: 16 Jun 2009
Total Posts: 20628
08 Oct 2014 08:08 PM
Somewhat close,

local parts = game.Workspace:GetChildren()
for i = 1,#parts do
if parts[i]:IsA("Hat") then --we're looking for the Hat instance under the workspace
parts[i].Handle.Name = parts[i].Name
parts[i].Handle.Parent = game.Workspace
parts[i]:Destroy() -- if you're done with it now.
end
end

I would use a generic for loop rather than a numeric loop, and I wouldn't call the table that holds all of the workspace's children "parts" because not all of children are parts.
Report Abuse
ForgotTheFood is not online. ForgotTheFood
Joined: 25 Oct 2010
Total Posts: 801
08 Oct 2014 08:11 PM
Nah it didn't work.

Like I said, all the parts are within a hat. I can simply move them out, but I want it to do a rename specifically, renaming the Handle inside the Hat("item") to the name of the Parent they are inside.
Report Abuse
ForgotTheFood is not online. ForgotTheFood
Joined: 25 Oct 2010
Total Posts: 801
08 Oct 2014 08:13 PM
@lordrambo, Nah it didn't work either.
Report Abuse
lordrambo is not online. lordrambo
Joined: 16 Jun 2009
Total Posts: 20628
08 Oct 2014 08:14 PM
What I wrote finds a hat in the workspace, change's the part inside of it to the hat's name, moves that part to the workspace, then deletes the hat. Is that not what you wanted?
Report Abuse
ForgotTheFood is not online. ForgotTheFood
Joined: 25 Oct 2010
Total Posts: 801
08 Oct 2014 08:16 PM
It is, The other message was to the fellow above your post.

But it didn't work sadly.
Report Abuse
ForgotTheFood is not online. ForgotTheFood
Joined: 25 Oct 2010
Total Posts: 801
08 Oct 2014 08:19 PM
The naming works, the moving, and deletion doesn't.
Report Abuse
128GB is not online. 128GB
Joined: 17 Apr 2014
Total Posts: 8056
08 Oct 2014 08:23 PM
local stuff = workspace:GetChildren()
for _, h in pairs (stuff) do
if h:IsA("Hat") and h:FindFirstChild("Handle") then
h.Handle.Name = h.Name
h[h.Name].Parent = workspace
h:Destroy()
end
end
Report Abuse
128GB is not online. 128GB
Joined: 17 Apr 2014
Total Posts: 8056
08 Oct 2014 08:24 PM
@Lord
The problem with yours is this

parts[i].Handle.Name = parts[i].Name
parts[i].Handle.Parent = game.Workspace


After you rename the Handle, parts[i].Handle no longer exists
Report Abuse
lordrambo is not online. lordrambo
Joined: 16 Jun 2009
Total Posts: 20628
08 Oct 2014 08:25 PM
It names every part but does not move it or delete the hat?
Report Abuse
ForgotTheFood is not online. ForgotTheFood
Joined: 25 Oct 2010
Total Posts: 801
08 Oct 2014 08:31 PM
Yes. @lord. Removing the move/deletion part of it makes it work for renaming, However with those in it, it doesn't rename it nore move it/delete hat.
Report Abuse
128GB is not online. 128GB
Joined: 17 Apr 2014
Total Posts: 8056
08 Oct 2014 08:31 PM
Mine does I tested it.
Report Abuse
lordrambo is not online. lordrambo
Joined: 16 Jun 2009
Total Posts: 20628
08 Oct 2014 08:34 PM
Oh yeah I didn't notice that. Nice catch
Report Abuse
ForgotTheFood is not online. ForgotTheFood
Joined: 25 Oct 2010
Total Posts: 801
08 Oct 2014 08:42 PM
Thanks c:
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