I've been trying to make a dragger which when you hold it moves it. All the positioning works but I have a problem with UserInputService. When trying to check if the button that was pressed was left mouse click, it did not register the click. I've checked it by doing this
inputservice.InputBegan:Connect(function(t) -- inputservice is a variable to UserInputService print(t.KeyCode) end)
and it prints out Enum.KeyCode.Unknown when clicking. Any potential fix?
local UserInputService = game:GetService("UserInputService") UserInputService.InputBegan:Connect(function() local Pressed = UserInputService:IsMouseButtonPressed(Enum.UserInputType.MouseButton1) if Pressed then print("Pressed") end end)
Hello well i might know the problem but i'll show you the code without explaining so try this:
local UserInputService = game:GetService("UserInputService") UserInputService.InputBegan:Connect(function(input, gameProcessed) if input.UserInputType == Enum.UserInputType.Keyboard then local keyPressed = input.KeyCode print(keyPressed) end end)