SetCore("ChatActive", true) doesn't work with TextChatService

You cannot set ChatActive to true so it’s impossible to setup a simple keybind to open a custom chat when the user presses “/”
Instead you have to do this jank:

local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")

local slashpressed 
UserInputService.InputBegan:Connect(function(input)
	slashpressed = input.KeyCode == Enum.KeyCode.Slash
end)

UserInputService.InputEnded:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.Slash then
		slashpressed = false
	end
end)

local laststate = true
local function laststateChanged(currentState)
	if not currentState then
		TextChatService.ChatInputBarConfiguration.Enabled = true
	elseif currentState then
		TextChatService.ChatInputBarConfiguration.Enabled = false
		if slashpressed then
			task.delay(0, function() -- and if you don't use task.delay it by a frame it doesn't let you type :/
				InputTextBox:CaptureFocus()
			end)
		end
	end
end

local function onHeartbeat(dt)
	local chatActive = StarterGui:GetCore("ChatActive")
	
	if laststate ~= chatActive then
		laststateChanged(chatActive)
		yourChatWindow.Visible = chatActive
		laststate = chatActive
	end
end

task.delay(1, function()
	RunService.RenderStepped:Connect(onHeartbeat)
end)

Duplicate:

1 Like