10 tries later ..
--LocalScript in StarterPlayerScripts
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local UIS = game:GetService("UserInputService")
local DropDownTextButtonTemplate = ReplicatedStorage:WaitForChild("DropDownTextButtonTemplate")
local MaterialFrame = script.Parent
local MaterialTextBox = MaterialFrame.Background1.TextBox
local DropDownScrollingFrameContainer = MaterialFrame.DropDownScrollingFrameContainer
local DropDownScrollingFrame = DropDownScrollingFrameContainer.DropDownScrollingFrame
local Materials = {
"Asphalt","Basalt","Brick","Cardboard","Carpet","CeramicTiles","ClayRoofTiles","Cobblestone",
"Concrete","CorrodedMetal","CrackedLava","DiamondPlate","Fabric","Foil","ForceField","Glacier",
"Glass","Granite","Grass","Ground","Ice","LeafyGrass","Leather","Limestone","Marble","Metal",
"Mud","Neon","Pavement","Pebble","Plaster","Plastic","Rock","RoofShingles","Rubber","Salt",
"Sand","Sandstone","Slate","SmoothPlastic","Snow","Wood","WoodPlanks"
}
local ClearTextOnFocus = true
local insertCloneReturnWord = {}
local MaterialChangedConnection = nil
local MaterialTextBoxPreviousText = MaterialTextBox.Text
local skipNextOverwrite = false
local function SelectMaterial(name)
skipNextOverwrite = true
MaterialTextBox.Text = name
MaterialTextBoxPreviousText = name
DropDownScrollingFrameContainer.Visible = false
end
for i, word in ipairs(Materials) do
local b = DropDownTextButtonTemplate:Clone()
b.Name = word
b.Text = word
b.LayoutOrder = i
b.BackgroundColor3 = (i % 2 == 1) and Color3.fromRGB(52,52,52) or Color3.fromRGB(49,49,49)
insertCloneReturnWord[b] = word
b.Parent = DropDownScrollingFrame
b.MouseButton1Click:Connect(function()
SelectMaterial(word)
end)
end
local function MaterialTextBoxFocused()
MaterialTextBoxPreviousText = MaterialTextBox.Text
if ClearTextOnFocus then MaterialTextBox.Text = "" end
DropDownScrollingFrameContainer.Visible = true
for c in pairs(insertCloneReturnWord) do c.Visible = true end
if MaterialChangedConnection then MaterialChangedConnection:Disconnect() end
MaterialChangedConnection = MaterialTextBox:GetPropertyChangedSignal("Text"):Connect(function()
if skipNextOverwrite then
skipNextOverwrite = false
return
end
local text = MaterialTextBox.Text:gsub("[^%a]", "")
if text == "" then
for c in pairs(insertCloneReturnWord) do c.Visible = true end
MaterialTextBoxPreviousText = ""
else
local lower = text:lower()
local matched = {}
for _, w in ipairs(Materials) do
if w:sub(1, #lower):lower() == lower then
matched[w] = true
end
end
for c, w in pairs(insertCloneReturnWord) do
c.Visible = matched[w] == true
end
if next(matched) then
MaterialTextBoxPreviousText = string.upper(lower:sub(1,1)) .. lower:sub(2)
end
end
MaterialTextBox.Text = MaterialTextBoxPreviousText
end)
end
MaterialTextBox.Focused:Connect(MaterialTextBoxFocused)
UIS.InputBegan:Connect(function(input, gp)
if gp then return end
if input.KeyCode == Enum.KeyCode.Return then
local t = MaterialTextBoxPreviousText:lower()
for _, w in ipairs(Materials) do
if w:sub(1, #t):lower() == t then
SelectMaterial(w)
break
end
end
end
if input.KeyCode == Enum.KeyCode.Escape then
MaterialTextBox.Text = MaterialTextBoxPreviousText
DropDownScrollingFrameContainer.Visible = false
end
end)
This one almost works.. it’s so close I could cry. If you hit enter twice it will take a few letters and make it the right choice. Going to have to start cheating here next.. I’ll leave that to your troll.