|
| 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
|
  |
| 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
|
  |
| 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 |
|
|
|
| 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 |
|
|
|
| 08 Oct 2014 08:13 PM |
| @lordrambo, Nah it didn't work either. |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 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 |
|
|
|
| 08 Oct 2014 08:19 PM |
| The naming works, the moving, and deletion doesn't. |
|
|
| Report Abuse |
|
|
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
|
  |
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| Joined: 17 Apr 2014 |
| Total Posts: 8056 |
|
| |
|
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 |
|
|
| |
|