Hello this is my first post here! So I was recreating the 2016 - 2020 Roblox topbar and need help making a custom chat button bind with chatbox visibility. My chat button works but the only thing is it does not unselect/select when i click the “/” button on the keyboard like the chatbox opens when you click that button. I looked all over the dev forum but found nothing that helped.
Here is the code:
local StarterGui = game:GetService("StarterGui")
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.All, false)
local Player = game.Players.LocalPlayer
local ChatMain = require(Player.PlayerScripts:WaitForChild("ChatScript").ChatMain)
local ChatToggle = script.Parent.Topbar.Left.Chat.Button
Textures = {
Backpack = {
Selected = "rbxasset://textures/ui/Backpack/Backpack_Down.png",
Unselected = "rbxasset://textures/ui/Backpack/Backpack.png"
},
Chat = {
Selected = "rbxasset://textures/ui/Chat/ChatDownFlip.png",
Unselected = "rbxasset://textures/ui/Chat/ChatFlip.png"
},
}
ChatToggle.MouseButton1Click:Connect(function()
ChatMain:ToggleVisibility()
ChatToggle.Selected = not ChatToggle.Selected
end)
ChatToggle:GetPropertyChangedSignal("Selected"):Connect(function()
if ChatToggle.Selected == true then
ChatToggle.Image = Textures.Chat.Selected
elseif ChatToggle.Selected == false then
ChatToggle.Image = Textures.Chat.Unselected
end
end)
I also have edited the Chat scripts in the Chat Service so the default chat button is not visible
game.Chat.ChatScript.ChatMain Line 523
moduleApiTable.CoreGuiEnabled:connect(function(enabled)
moduleApiTable.IsCoreGuiEnabled = true
enabled = true
ChatWindow:SetCoreGuiEnabled(enabled)
if (not enabled) then
ChatBar:ReleaseFocus()
InstantFadeOut()
else
InstantFadeIn()
end
end)
Here is a video depicting the issue
https://youtu.be/EdA2SAhQqRE
As you see in the video when i click the button it works fine but when i click “/” on my keyboard it doesn’t select the button, but the chatbox still turns on. I need the button to get selected when you click “/” on the keyboard.
Thank you for your help!