Roblox provides a super handy property for this UserInputService:GetFocusedTextBox() or checking input.UserInputType & input.UserInputState along with input:IsDescendantOf().
But here’s the best general fix
local UserInputService = game:GetService("UserInputService")
UserInputService.InputBegan:Connect(function(input, gameProcessed)
if gameProcessed then return end -- UI was clicked, don't attack
if input.UserInputType == Enum.UserInputType.MouseButton1 then
-- Run your M1 combat attack logic here
print("M1 Attack!")
end
end) Use gameProcessed to ignore clicks on UI, and maybe set a manual flag like inDialogue if needed. That’ll keep combat and UI cleanly separated.