Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Gus buttons overlapping in scrolling frame. Why?

Asked by 1 year ago
Edited 1 year ago

This script works completely fine and it may be the scrollingframe itself but when the buttons are parented to the scrolling frame which has the “UIList” the buttons overlap each other and aren’t in a list format. (This script is a chat autofill script)

Example: https://streamable.com/03dhtp (Copy link and paste)

Script:

local Chat = game.Players.LocalPlayer.PlayerGui:WaitForChild("Chat")
local ChatBar = Chat.Frame.ChatBarParentFrame.Frame.BoxFrame.Frame.ChatBar


local presetStrings = {
    "Poena Doloris",
    "Phasmatos Immortalis",
    "Post Tenebras Spero Lucem",
    "Incendia",
    "Ossox",
    "Delfan Eoten Cor"
}


local chatBox = ChatBar


local autoFillCollectionButtons = script.Parent.Frame.ChatBarParentFrame.Buttons
local autoFillCollectionFrame = script.Parent.Frame
local listLayout = Instance.new("UIListLayout")
listLayout.Parent = autoFillCollectionButtons
listLayout.SortOrder = Enum.SortOrder.LayoutOrder
listLayout.Padding = UDim.new(0, 5)
listLayout.FillDirection = Enum.FillDirection.Horizontal
listLayout.VerticalAlignment = Enum.VerticalAlignment.Top
listLayout.HorizontalAlignment = Enum.HorizontalAlignment.Left

function refreshAutofillSuggestions()
    local input = ChatBar.Text
    if input == "" or input == presetStrings then 
        autoFillCollectionFrame.Visible = false 
        return 
    end

    autoFillCollectionButtons:ClearAllChildren()
    for _, presetString in ipairs(presetStrings) do
        if input:sub(1,1):lower() == presetString:sub(1,1):lower() then
            autoFillCollectionFrame.Visible = true

            local button = Instance.new("TextButton")
            button.BorderSizePixel = 0
            button.Text = presetString
            button.TextColor3 = Color3.fromRGB(255, 255, 255)
            button.BackgroundTransparency = 0.6
            button.Parent = autoFillCollectionButtons
            button.AutomaticSize = Enum.AutomaticSize.XY
            button.Size = UDim2.new(0, 128,0, 26)
            button.Font = Enum.Font.GothamBold
            button.TextSize = 16
            print(button.Text)

            button.MouseButton1Click:Connect(function()
                chatBox.Text = presetString     
                autoFillCollectionFrame.Visible = false



                end)
            end
    end
end

chatBox:GetPropertyChangedSignal("Text"):Connect(refreshAutofillSuggestions)

Answer this question