I'm currently working on a game and I wanted to make my own Chat GUI. I have the chats displaying on the screen but I wanted to also make a Chat Bar.
My problem is that I am checking for when the player presses the "/" key, but sometimes the event doesn't fire when the player presses that key.
My code :
-- mouse is the players mouse. -- gui is the chatgui all the gui objects are being stored in. mouse.KeyDown:connect(function(key) if key == "/" then gui.ChatBox.ChatBox.Text = "" gui.Label:TweenPosition(UDim2.new(0.05,0,1,0), "Out", "Quad", 1, true) gui.ChatBox:TweenPosition(UDim2.new(0,0,0.95,0), "Out", "Quad", 1, true) gui.ChatBox.ChatBox:CaptureFocus() end end)
Anyone have any ideas to fix this I've seen other games do this but not sure how they did it.
local Player = game.Players.LocalPlayer local Mouse = Player:GetMouse() Mouse.KeyDown:connect(function(Key) if key == string.char(47) then -- This is the shift key. gui.ChatBox.ChatBox.Text = "" gui.Label:TweenPosition(UDim2.new(0.05,0,1,0), "Out", "Quad", 1, true) gui.ChatBox:TweenPosition(UDim2.new(0,0,0.95,0), "Out", "Quad", 1, true) gui.ChatBox.ChatBox:CaptureFocus() end)
Special Keys Maybe you can try using ContollerService on wiki to help. I believe this "/" key is already in use for the regular roblox, though I have a feeling that your making a custom chat which gets rid of roblox chat using SetCoreGuiEnabled. But I guess there is a way to unbind the "/" and use it but till then you can use other keys.