How to disable arrow key movement without disabling use of arrow keys

Basically what I want to do is similar to this post, (How do I disable arrow keys?) which is disable arrow keys, but instead I want to be able to use the arrow keys to move a gui around.

The issue with this post is that it makes the arrow keys unusable.

It would be helpful if you were a lot more specific, because this can mean virtually anything.
Though I made an attempt, and using a script in the post you linked, the input will still get detected by the UserInputService. With that, you can do ‘something else’.

E.g:

local ContextActionService = game:GetService("ContextActionService")
local UserInputService = game:GetService("UserInputService")

ContextActionService:BindActionAtPriority("DisableArrowKeys", function()
	return Enum.ContextActionResult.Sink
end, false, Enum.ContextActionPriority.High.Value, Enum.KeyCode.Up, Enum.KeyCode.Down, Enum.KeyCode.Left, Enum.KeyCode.Right)

UserInputService.InputBegan:Connect(function(input, gameProcessedEvent)
	
	if input.KeyCode == Enum.KeyCode.Up or input.KeyCode == Enum.KeyCode.Down or input.KeyCode == Enum.KeyCode.Left or input.KeyCode == Enum.KeyCode.Right then
		local fullInput = tostring(input.KeyCode)
		print(string.sub(fullInput, 14), "arrow detected.")
	end
	
end)

Sorry! What I am trying to do is use the arrow keys to move a gui around. I will look at your solution, thank you

Basically how you could handle this. Probably not exactly how you would want to handle this depending on how/when it’s being used. More of a starting point …

-- ServerScript in ServerScriptService

local Players = game:GetService("Players")
local UIS = game:GetService("UserInputService")

Players.PlayerAdded:Connect(function(player)
    local character = player.Character or player.CharacterAdded:Wait()
    local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
    humanoidRootPart.Anchored = true

    UIS.InputBegan:Connect(function(input, gameProcessed)
        if not gameProcessed then
            if input.UserInputType == Enum.UserInputType.Keyboard then
                if input.KeyCode == Enum.KeyCode.Up then
                elseif input.KeyCode == Enum.KeyCode.Down then
                elseif input.KeyCode == Enum.KeyCode.Left then
                elseif input.KeyCode == Enum.KeyCode.Right then
                end
            end
        end
    end)

    UIS.InputEnded:Connect(function(input)
        if input.UserInputType == Enum.UserInputType.Keyboard then
            if input.KeyCode == Enum.KeyCode.Up then
            elseif input.KeyCode == Enum.KeyCode.Down then
            elseif input.KeyCode == Enum.KeyCode.Left then
            elseif input.KeyCode == Enum.KeyCode.Right then
            end
        end
    end)
end)

The solution was just not to check for game processed event when using userinputservice. Thanks

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.