Hello!
I was just wondering how I would go about creating a keybind system. I want to make a reset button, this default key is R, however when pressing on the key, after pressing the key, it’s still interact-able, which I want to avoid. I decided I wanted to try ContextActionService, however this can only be done with a single key/input type. What do I do now?
In the video, you can see it can be pressed multiple times, only after first pressing the button.
Here’s my script:
local UIS = game:GetService('UserInputService')
script.Parent.MouseButton1Click:Connect(function()
script.Parent.Over.Visible = false
script.Parent.Under.TextLabel.Text = '> <'
UIS.InputBegan:Connect(function(key, isSystemReserved)
if not isSystemReserved then
if string.len(key.KeyCode.Name) == 1 then
print(key.KeyCode.Name)
script.Parent.Over.Visible = true
script.Parent.Over.TextLabel.Text = key.KeyCode.Name
return
end
end
end)
end)
script.Parent.MouseButton1Down:Connect(function()
script.Parent.Over.Visible = false
end)