|
| 10 Feb 2017 05:35 PM |
How can i detect every part that has a specific name like : " hi "
|
|
|
| Report Abuse |
|
|
Treeecow
|
  |
| Joined: 10 Jun 2011 |
| Total Posts: 5161 |
|
| |
|
| |
|
|
| 10 Feb 2017 05:41 PM |
| for i,v in ############################ ## # = Instance.new("Folder", workspace) if ###### ## "hi" then ######## = game.Workspace.Folder end end |
|
|
| Report Abuse |
|
|
| |
|
|
| 10 Feb 2017 05:47 PM |
function recurse(Model) local children = Model:GetChildren() for i = 1,#children do if children[i]:IsA("Part") and children[i].Name == "hi" then print("Part found") elseif children[i]:IsA("Model") then recurse(children[i]) end end end
recurse(Workspace)
1) Cycle through workspace, find all parts with specified name 2) Cycle through models inside workspace, find all parts with specified name 3) Cycle through models inside other models, find all parts with specified name
Hope this helped
|
|
|
| Report Abuse |
|
|
|
| 10 Feb 2017 05:59 PM |
i dont really understand so i cant really make a command from it
|
|
|
| Report Abuse |
|
|
|
| 10 Feb 2017 06:19 PM |
depends on where you are looking for it.
here is my script, it will always find the part, but it will look everywhere so it may not be efficient.
ObjectName="hi" --Name of thing we are looking for ObjectClassName="Part" --Type of thing we are looking for
Directories={--look for the thing in these directories game.Lighting, game.Workspace, game.Players, game.ReplicatedFirst, game.ReplicatedStorage, game.ServerScriptService, game.ServerStorage, game.StarterGui, game.StarterPack, game.StarterPlayer, game.Soundscape }
function Find(ObjectName,ObjectClassName,Directory,Iteration) local DirectoryName=Directory.Name local Di################################# local St################################# print(Stylize..'Searching for "'..ObjectName..'" in '..DirectoryName) for i=1,#Directory do if Directory[i].ClassName==ObjectClassName and Directory[i].Name==ObjectName then print(Stylize..'Found "'..ObjectName..'" in "'..DirectoryName..'"') return(Directory[i]) else print(Stylize..'"'..ObjectName..'" not found in "'..DirectoryName..'" ('..DirectoryName..'.'..Directory[i].Name..')') if #Directory[i]:GetChildren()>0 then --has children print(Stylize..'+Searching for "'..ObjectName..'" in '..DirectoryName..'.'..Directory[i].Name) Find(ObjectName,ObjectClassName,Directory[i],Iteration+1) end end end end
for i=1,#Directories do ########################################################## ObjectValue (pointer to found object) end |
|
|
| Report Abuse |
|
|
|
| 10 Feb 2017 06:20 PM |
Welp, it censored (as expected)
here is a link to it in script form (without hash tags)
https://www.roblox.com/catalog/649282189 |
|
|
| Report Abuse |
|
|
|
| 10 Feb 2017 06:21 PM |
Oops, malformed link. Here is the right one
https://www.roblox.com/catalog/649282189/item |
|
|
| Report Abuse |
|
|
|
| 10 Feb 2017 06:24 PM |
function _G.recurse(Model,string) local children = Model:GetChildren() for i = 1,#children do if children[i]:IsA("Part") and children[i].Name == string then print("Part found") elseif children[i]:IsA("Model") then recurse(children[i]) end end end
Put this into any script, now you can call _G.recurse() with your F9 console or from any other script.
"Model" is the model you want to begin searching in. "string" is the name of the part you are searching for.
_G.recurse(Workspace,"hi") will search Workspace and all models that are children of workspace for any part named "hi"
|
|
|
| Report Abuse |
|
|