I am creating a shop gui that will open and close when the players chosen key is pressed. I found out how to find the key, but not stop detecting the key after a key is pressed for the first time. Heres my code:
but = script.Parent local UIS = game:GetService("UserInputService") local player = game:GetService("Players").LocalPlayer local mouse = player:GetMouse() local function inputDetecter() repeat UIS.InputBegan:Connect(function(key, gp) print(key.KeyCode) but.KeyVal = tostring(key.KeyCode) end) until mouse.KeyDown end but.MouseButton1Click:Connect(function() inputDetecter() end)
If you want to detect when the player releases a key then try
UIS.InputEnded:Connect(function(key, gp) print(key.KeyCode.. " was released!") end)