In a game I am working on, a certain UI portion is only to be shown while the default roblox chat is actively opened. Whenever you close the chat, the desired UI is still showing, looking very weird.
Is there an event of some sort that comes with toggling ChatActive?
I have already thought of using StarterGui:GetCore("ChatActive"). However, I am pretty sure it is bad to call this repeatedly in order to make the UI update instant.
So, is there any way to get around this? I feel like I have seen other games with custom chats use this in order to make their chat align with the toggle-able chat button on the top bar.
Looks like chatactive has an issue where it doesnt change if the / key is pressed. If you really wanted to maintain this feature, your only option would be to manually detect when the last time the / key was pressed. This seems to work reliably, but it’s really ghetto tbh.
local StarterGui = game:GetService('StarterGui')
local playerGui = game.Players.LocalPlayer:WaitForChild('PlayerGui')
local screenGui = playerGui:WaitForChild('ScreenGui')
local last = not StarterGui:GetCore("ChatActive")
local onOpposite = false
screenGui.Enabled = last
game:GetService('UserInputService').InputBegan:Connect(function(input, process)
if input.KeyCode == Enum.KeyCode.Slash then
if not last then
onOpposite = not onOpposite
screenGui.Enabled = last
last = not last
end
end
end)
while true do
local on = StarterGui:GetCore("ChatActive")
if onOpposite then
on = not on
end
if on == not last then
last = on
screenGui.Enabled = not on
end
wait()
end
Edit: I just realized you want something to enable when chat is enabled, so uh just set the parts that set the screengui to enabled to the opposite I guess