I am making a custom chat, which uses the same thing as kinda like roblox's chat but I disabled the coregui for chat. This works in studio but doesnt work in player so It must be something to do with the keybyte() == 47 anyone know how to enable it?
local player = game.Players.LocalPlayer local mouse = player:GetMouse() local able = false local default = script.Default function onkey(key) if key:byte() == 47 then script.Parent:TweenSizeAndPosition(UDim2.new(1,0,.05,0), UDim2.new(0,0,.45,0), "Out", "Quad", .5, true) script.Parent.TextXAlignment = "Center" script.Parent:CaptureFocus() able = true end end function clear() script.Parent:TweenSizeAndPosition(UDim2.new(1,0,.025,0), UDim2.new(0,0,.975,0), "Out", "Quad", .5, true) script.Parent.TextXAlignment = "Left" able = false script.Parent.Text = default.Value end mouse.KeyDown:connect(onkey) script.Parent.FocusLost:connect(clear)
I'd recommend using UserInputService instead of KeyDown as it will take in any human interaction (including keyboard presses) regardless of game state.
Also you don't have to mess around with key bytes (some keys have different byte codes in studio vs client, some have the same as others, etc) and can just use the KeyCode Enum instead.
game:GetService("UserInputService").InputBegan:connect(function(input) if input.KeyCode == Enum.KeyCode.Slash then --code end end