local uis = game:GetService("UserInputService")
uis.InputBegan:Connect(function(keycode)
if keycode == Enum.KeyCode.E then
print("pressed:)")
end
end)
uis.InputEnded:Connect(function(keycode)
if keycode == Enum.KeyCode.E then
print("pressended")
end
end)
I know it’s already been resolved but I’ll improve it.
local CAS = game:GetService("ContextActionService")
local UIS = game:GetService("UserInputService")
--[[
local function Dispositive()
return UIS.TouchEnabled and "Mobile" or UIS.GamepadEnabled and "XBOX" or "PC"
end
]] -- You don't need this, but work.
local function HoldKey(Name, State, Object)
if State == Enum.UserInputState.Begin then
print("Holding!")
elseif Enum.UserInputState.End then
print("Stopped Holding...")
end
end
CAS:BindAction("Hold",HoldKey,true,Enum.KeyCode.E, Enum.KeyCode.ButtonL1)
-- Name, function, buttonToMobile, Input1 or Input2
CAS:SetTitle("Hold", "HoldKey")