local frame2searchbox1 = Instance.new("TextBox",frame2) frame2searchbox1.Size = UDim2.new(.75,0,.15,0) frame2searchbox1.Position = UDim2.new(.125,0,0,0) frame2searchbox1.Name = "SearchChildrenBox" frame2searchbox1.BackgroundColor3 = Color3.new(1,1,1) frame2searchbox1.Text = "Enter Where to search here - Ex. game.Workspace" frame2searchbox1.TextScaled = true local frame2searchbox1val = Instance.new("StringValue",frame2searchbox1) frame2searchbox1.Changed:Connect(function() frame2searchbox1val.Value = frame2searchbox1.Text frame2searchbox1val.Name = "Value" end) local function searchfunction1(text) for i,v in (text:GetChildren())do print(v.Name) wait(.1) end end local frame2searchbutton1 = Instance.new("TextButton",frame2) frame2searchbutton1.Size = UDim2.new(.75,0,.15,0) frame2searchbutton1.Position = UDim2.new(.125,0,0.15,0) frame2searchbutton1.Name = "SearchChildren" frame2searchbutton1.BackgroundColor3 = closebutton.BackgroundColor3 frame2searchbutton1.Text = "Find Children" frame2searchbutton1.Activated:Connect(function() local text = frame2searchbox1.Value.Value print "Searching.." print"===========================" searchfunction1(text) end)
Basically all i want to do is make a button that when clicked it will print the children of whatever is typed in the box for example game.Workspace
This function might come in handy:
function FindObjOnPath(path) local nodot = string.gsub(path,'%.',' ') local nogame = string.gsub(nodot,'game','') local words = {} local returnobj = game for v in string.gmatch(nogame,'%S+') do table.insert(words,v) end for i,v in pairs(words) do returnobj = returnobj[v] end return returnobj end
Add this function into your script, and replace searchfunction1 with this:
local function searchfunction1(text) local object = FindObjOnPath(text) for i,v in pairs(object:GetChildren())do print(v.Name) end end
The FindObjOnPath function uses string manipulation to find the object on the given path. I'll explain what it does:
It takes the given path, and removes all dots in the string. Then, it takes out 'game' from the string. It then loops through all the words and uses some weird hacky stuff that I don't really know how I can explain. You can try looking at my function yourself to understand it.