Plugin Input problems

I am writing a plugin for UI that will allow to set anchors in GUI like in Unity. And I need to understand whether I pressed shift or not.
With shift I will change position and without AnchorPoint only.

But my input works only when my mouse is in Viewport.
How to fix this? I tried depricated methods, they don’t work either.

----------------------------------------------------------------
-- Input State
----------------------------------------------------------------
local isShiftPressed = false
local anchorGrid: any = nil
local statusLabel: TextLabel? = nil  -- объявили тут

local function setShiftState(state: boolean)
	if isShiftPressed ~= state then
		isShiftPressed = state
		if anchorGrid then
			anchorGrid.UpdateColors(isShiftPressed)
		end
	end
end

UserInputService.InputBegan:Connect(function(input, processed)
	if not processed and input.KeyCode == Enum.KeyCode.LeftShift then
		setShiftState(true)
	end
end)

UserInputService.InputEnded:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.LeftShift then
		setShiftState(false)
	end
end)

1 Like

Have you tried removing not processed?

yes thats not working too, because event stop firing

Try using ContextActionService.

If that doesn’t work, try GuiObject.InputBegan.