Why can't I get the player's chatbox?

  1. What do you want to achieve? An autofill script

  2. What is the issue? The script can’t find the player’s default chatbox

  3. What solutions have you tried so far? I’ve tried to copy paste the chat gui and remake it and mess around with it but that has only made it worse.

here’s a script that i partially got from another similar post

local presetStrings = {"Incendia"}

--local player = game.Players.LocalPlayer
--local Character = player.Character

--for i, v in pairs(Character:WaitForChild("Powers").Spells:GetDescendants()) do
--	if v:IsA("LocalScript") then
--		table.insert(presetStrings, v.Name)
--	end
--end

-- We'll store the chatBox outside of the loop.
local chatBox = game.Players.LocalPlayer.PlayerGui.Chat.Frame.ChatBarParentFrame.Frame.BoxFrame.Frame.ChatBar


local autoFillCollectionFrame = script.Parent.ScrollingFrame

function refreshAutofillSuggestions(chatBox)
	autoFillCollectionFrame:ClearAllChildren()

	for _, presetString in pairs(presetStrings) do
		if chatBox.Text:lower():match(presetString:lower()) then

			local button = Instance.new("TextButton")
			button.Text = presetString
			button.Parent = autoFillCollectionFrame

			button.MouseButton1Click:Connect(function()
				chatBox.Text = presetString
			end)
		end
	end
end

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

all help is appreciated

the player’s chat box is a coregui you cannot access coregui through scripts, if you want autofill you need to recreate a chat system

1 Like